minetest-mods / craftguide

:book: The most comprehensive Crafting Guide on Minetest
Other
43 stars 20 forks source link

code optimization/cleanup, rebuild the item list on demand only #47

Closed bell07 closed 5 years ago

bell07 commented 5 years ago

In preparation to get the progressive-mode replaceable, and to understand how the mod work I did some optimizations.

Main change is: The text-filter is applied at the first now, and the progressive filter at the second. The goal is to improve performance for high items volume (I test with my whynot game). Therefore no data.init_filter_items or searches[] cache usefull anymore. My changes did improved the performance for me. But I look for further performance optimizations.

By the way, in smart_inventory I pre-analyze all recipes at server-boot and cache needed informations in lua tables for faster access. Interested for something similar in craftguide?

kilbith commented 5 years ago

The searches cache is here to avoid looping through all items if the result is known (after 2 searches). Your changes force looping whatsoever, so explain me why the cache isn't useful anymore?

Interested for something similar in craftguide?

Yes.

bell07 commented 5 years ago

I started the work on this before I seen you work on API function too.

Now I will test your canges and if your PR is well-tested and merged, I rebase this PR and look for further optimizations.

EDIT: shortly tested your work, there is a performance boost in progressive ;-) beter then my changes in this PR

bell07 commented 5 years ago

Ok, this PR is pointless now since #46 is merged. If I see further optimizations I create new PR. Thank you for your support. Now I understand little more how the craftguide work