mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
Use split limit
This commit is contained in:
@@ -30,7 +30,7 @@ class EstimateDirection {
|
||||
static boolean isRTL(String str) {
|
||||
int rtlCount = 0;
|
||||
int total = 0;
|
||||
String[] tokens = WORD_SEPARATOR_RE.split(str);
|
||||
String[] tokens = WORD_SEPARATOR_RE.split(str, 20); // limit splits to 20, usually enough
|
||||
for (int i = 0; i < tokens.length; i++) {
|
||||
String token = tokens[i];
|
||||
if (startsWithRtl(token)) {
|
||||
@@ -41,11 +41,6 @@ class EstimateDirection {
|
||||
} else if (hasAnyLtr(token)) {
|
||||
total++;
|
||||
}
|
||||
|
||||
// only checking 20 first words is usually enough
|
||||
if (i == 20) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return total == 0 ? false : ((float) rtlCount / total > RTL_DETECTION_THRESHOLD ? true : false);
|
||||
|
||||
Reference in New Issue
Block a user