Skip to content

Commit b48e54b

Browse files
committed
autocomplete [nfc]: Simplify and clarify docs on comparator methods
The details of negative vs. positive vs. zero return values are part of the interface of comparators in general. The details of 1 vs. any other positive value, or -1 vs. any other negative value, are implementation details of the methods -- callers should only care about negative vs. positive vs. zero.
1 parent b36ba88 commit b48e54b

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lib/model/autocomplete.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,7 @@ class MentionAutocompleteView extends ChangeNotifier {
320320
};
321321
}
322322

323-
/// Compares the bot status of two users and returns an integer indicating their order.
324-
///
325-
/// Returns `-1` if `userA` is human and `userB` is bot, returns `1` if `userA`
326-
/// is bot and `userB` is human, and returns `0` if both users have the same
327-
/// bot status.
323+
/// Comparator that puts non-bots before bots.
328324
@visibleForTesting
329325
static int compareByBotStatus(User userA, User userB) {
330326
return switch ((userA.isBot, userB.isBot)) {
@@ -334,11 +330,7 @@ class MentionAutocompleteView extends ChangeNotifier {
334330
};
335331
}
336332

337-
/// Compares the two users by [User.fullName] case-insensitively.
338-
///
339-
/// Returns a negative number if `userA`'s `fullName` comes first alphabetically,
340-
/// returns a positive number if `userB`'s `fullName` comes first alphabetically,
341-
/// and returns `0` if both users have identical `fullName`.
333+
/// Comparator that orders alphabetically by [User.fullName].
342334
@visibleForTesting
343335
static int compareByAlphabeticalOrder(User userA, User userB,
344336
{required PerAccountStore store}) {

0 commit comments

Comments
 (0)