Recycling Tables, is it a good idea?
I thought I'd recently read something about whether recycling tables in lua was a good idea or not, but despite a lot of searching I couldn't find it.
I'm maintaining an addon that has table recycling, and if it really is a performance improvement then I'm okay with leaving it, but otherwise I prefer simple code. What is the current state of this practice? |
You most likely don't have to (shouldn't) worry about it. If you're dealing with fairly large tables and/or frequently creating new ones it might be worth considering.
|
If the person who wrote it thought it was worth the extra effort to implement, it probably wouldn't be a good idea to take it out just to simplify the code, at least not unless you're quite certain it's redundant.
|
Quote:
However, w/o knowing the addon or the code or the logic behind it, it's impossible to say if it should be retained or not. There are still very good reasons to do it under certain circumstances. So the generic answer is: if it isn't broke, don't fix it. The generic answer if you want to do a bit if work is: do a version w/o it and then profile each. Addons that use a lot of tables, esp large ones rebuilt for short durations, will tend to have some form of recycling but that most addons aren't complex enough to worry about it overmuch, but again it is very dependent on the addon. Edit: I'm assuming Autobar is the addon. If so, I think it predates the incremental garbage collection so it'd recycle its tables. It's been years since I poked around trying to repair Autobar so I can't recall the kind of table usage it necessitates. |
Quote:
I'm pretty sure that regardless of whether this would be a good place to do it, this implementation simply doesn't work. Here is the "Recycle" function: Code:
function Recycle.prototype:Recycle() |
Quote:
Quote:
Quote:
|
Quote:
My gut feeling is that it should be removed at this point just out of safety. |
All times are GMT -6. The time now is 08:58 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI