summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2022-11-14 05:19:01 +0000
committerOmar Rizwan <omar@omar.website>2022-11-14 05:19:01 +0000
commit0f0561a483eefaf330c189c1cc418957eb30fef4 (patch)
treea4b51a732df33a9191872d1d6cda1cf9b1d3b1d5
parentcalibration: new/more reliable sparse correspondence calc (diff)
downloadfolk-0f0561a483eefaf330c189c1cc418957eb30fef4.tar.gz
folk-0f0561a483eefaf330c189c1cc418957eb30fef4.zip
trie-c-play: Small short-circuit speedup(?)
-rw-r--r--useful/trie-c-play.tcl18
1 files changed, 9 insertions, 9 deletions
diff --git a/useful/trie-c-play.tcl b/useful/trie-c-play.tcl
index 95ab58bb..20938e22 100644
--- a/useful/trie-c-play.tcl
+++ b/useful/trie-c-play.tcl
@@ -264,16 +264,16 @@ namespace eval ctrie {
for (int j = 0; j < trie->nbranches; j++) {
if (trie->branches[j] == NULL) { break; }
- int potentialMatch = 0;
- potentialMatch = potentialMatch || (trie->branches[j]->key == wordv[0]);
- const char *keyString = Tcl_GetString(trie->branches[j]->key);
- const char *wordString = Tcl_GetString(wordv[0]);
- potentialMatch = potentialMatch ||
- (keyString[0] == '/') ||
- (wordString[0] == '/') ||
- (strcmp(keyString, wordString) == 0);
- if (potentialMatch) {
+ if (trie->branches[j]->key == wordv[0]) {
lookupImpl(interp, results, trie->branches[j], wordc - 1, wordv + 1);
+ } else {
+ const char *keyString = Tcl_GetString(trie->branches[j]->key);
+ const char *wordString = Tcl_GetString(wordv[0]);
+ if ((keyString[0] == '/') ||
+ (wordString[0] == '/') ||
+ (strcmp(keyString, wordString) == 0)) {
+ lookupImpl(interp, results, trie->branches[j], wordc - 1, wordv + 1);
+ }
}
}
}