RyanEdwardHall / anagrambler

Finds all anagrams and sub-anagrams in a string
MIT License
4 stars 1 forks source link

Track searched runes and bail if revisiting #4

Closed mcgid closed 8 years ago

mcgid commented 8 years ago

If we've already search()ed for a rune, all of its results will be duplicates. So we can fail early on that. (In other words, if our search string has duplicate runes, we can skip over the results from the duplicated runes.)

Also, if we're revisiting a node for any other reason, we've already traversed all results below it, so we can return early in that case.

This patch leads to staggering, almost incomprehensible speedups.