Merge "[PS] Return earlier if the input is null for matches." into main

This commit is contained in:
Holly Jiuyu Sun
2024-03-26 21:30:04 +00:00
committed by Android (Google) Code Review
@@ -18,6 +18,8 @@ package com.android.launcher3.search;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.android.launcher3.util.IntArray;
import java.text.Collator;
@@ -120,7 +122,11 @@ public class StringMatcherUtility {
/**
* Returns true if {@param query} is a prefix of {@param target}
*/
public boolean matches(String query, String target) {
public boolean matches(@Nullable String query, @Nullable String target) {
// `mCollator.compare` requires non-null inputs, so return false earlier (not a match)
if (query == null || target == null) {
return false;
}
switch (mCollator.compare(query, target)) {
case 0:
return true;