From 429f69cb7b9f1b52fc1f8a7471420e235d8c1883 Mon Sep 17 00:00:00 2001 From: Istvan Soos Date: Fri, 6 Dec 2024 14:57:48 +0100 Subject: [PATCH] Reduce complexity of 'normalizeBeforeIndexing' method. --- app/lib/search/text_utils.dart | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/lib/search/text_utils.dart b/app/lib/search/text_utils.dart index db1324da59..9c9ac2b3d0 100644 --- a/app/lib/search/text_utils.dart +++ b/app/lib/search/text_utils.dart @@ -11,7 +11,7 @@ import '../shared/markdown.dart'; final _separatorChars = '_.?!,;:=()<>[]{}~@#\$%&|+-*\\/"\'`'; final _escapedSeparators = _separatorChars.split('').map((s) => '\\$s').join(); final _separators = RegExp('[$_escapedSeparators]|\\s'); -final RegExp _nonCharacterRegExp = RegExp('[^a-z0-9]'); +final _nonCharactersRegExp = RegExp('[^a-z0-9]+'); final RegExp _multiWhitespaceRegExp = RegExp('\\s+'); final RegExp _exactTermRegExp = RegExp(r'"([^"]+)"'); @@ -58,12 +58,7 @@ String compactReadme(String? text) { String normalizeBeforeIndexing(String? text) { if (text == null) return ''; - final String t = text - .toLowerCase() - .replaceAll(_nonCharacterRegExp, ' ') - .replaceAll(_multiWhitespaceRegExp, ' ') - .trim(); - return t; + return text.toLowerCase().replaceAll(_nonCharactersRegExp, ' ').trim(); } Iterable splitForIndexing(String? text) {