Closed GreenComfyTea closed 2 years ago
All valid points, though yeah I'm not sure about what the custom indexers do behind the scenes. But still, it's kind of just a hassle and increases complexity to cache these things so I didn't for the sake of simplicity. For the most part none of this runs on update or anything, they're one offs whenever they're called so it's negligible anyway. Especially since it's just options menu code and not gameplay code I don't feel the need to make sure it's all optimal vs just being easier to read.
True. I saw you did cache stuff in the example script so decided to suggest this even thou its one-time calls, just for the code style uniformity reasons.
It's kinda all over the place, programming in lua sucks.
1) In
ModOptionsMenu/ModMenuApi.lua
you are calling a couple of methods of GuiManager by passing method name as a string insidePromptMsg
andPromptYN
functions:In this case it performs a hashmap lookup. You can cache the method.
2) In the same functions you call methods with custom indexers, but I don't know if it does a hashmap lookup or not. Probably not.
3) In the same places for getting
GuiManager
you callsdk.get_managed_singleton
. Since this is a singleton you can cache it the first time you need it, or even maybe during initialization, and the just use it.