diff options
| author | Omar Rizwan <omar@omar.website> | 2022-11-14 05:19:01 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2022-11-14 05:19:01 +0000 |
| commit | 0f0561a483eefaf330c189c1cc418957eb30fef4 (patch) | |
| tree | a4b51a732df33a9191872d1d6cda1cf9b1d3b1d5 | |
| parent | calibration: new/more reliable sparse correspondence calc (diff) | |
| download | folk-0f0561a483eefaf330c189c1cc418957eb30fef4.tar.gz folk-0f0561a483eefaf330c189c1cc418957eb30fef4.zip | |
trie-c-play: Small short-circuit speedup(?)
| -rw-r--r-- | useful/trie-c-play.tcl | 18 |
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); + } } } } |
