Merge "[PS] Return earlier if the input is null for matches." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
5455931d9d
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user