Kromtec / LegendsViewer

Recreates Dwarf Fortress' Legends Mode from exported files.
GNU General Public License v3.0
62 stars 19 forks source link

Fixes to historical figure curse filtering. #1

Closed Alexei-B closed 8 years ago

Alexei-B commented 8 years ago

Curses (vampires, werebeasts) were being filtered by searching for exact matches to the curse name (E.G. "VAMPIRE"), however this did not match the curse strings in the active interactions. Filtering (and historical figure naming based on curses) was fixed by using a search through all active interactions for strings that contained the sub-string of the curse name.

This method for determining if a historical figure is cursed has the issue that it searches through all active interactions for the respective sub-strings, when really only an initial match is necessary. This performance hit however does not seem significant in comparison the simplicity of the solution.

Kromtec commented 8 years ago

Awesome, thanks for contributing!

Short feedback: Whenever you can use .Any() instead of .Count() > 0 do it. https://dzone.com/articles/linq-performance-count-and-any

So instead of ActiveInteractions.Where(it => it.Contains("VAMPIRE")).Count() > 0 you could use ActiveInteractions.Count(it => it.Contains("VAMPIRE")) > 0 or even better ActiveInteractions.Any(it => it.Contains("VAMPIRE"))