Navigation menu

WoW:USERAPI EraseTable: Difference between revisions

Jump to navigation Jump to search
m
Move page script moved page USERAPI EraseTable to WoW:USERAPI EraseTable without leaving a redirect
m (Added comment about a more effective way to erase a table)
m (Move page script moved page USERAPI EraseTable to WoW:USERAPI EraseTable without leaving a redirect)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{localuserfunc}}
{{userfunc}}


'''EraseTable''' erases a table, often a good way to reduce garbage creation. Note that erasing a table can be more expensive than letting the GC system reclaim it, so one might prefer simply reallocating a new empty table. Also, note that a hash (as opposed to a 1..n integer-index) will NEVER SHRINK. Each key you ever used will use ~40 bytes and keep doing so until the table is destroyed. If you re-use the same keys this is obviously a nonissue.
'''EraseTable''' erases a table, often a good way to reduce garbage creation. Note that erasing a table can be more expensive than letting the GC system reclaim it, so one might prefer simply reallocating a new empty table. Also, note that a hash (as opposed to a 1..n integer-index) will NEVER SHRINK. Each key you ever used will use ~40 bytes and keep doing so until the table is destroyed. If you re-use the same keys this is obviously a nonissue.
Line 8: Line 8:
  for i in pairs(t) do t[i] = nil end
  for i in pairs(t) do t[i] = nil end
  end
  end
----
Would think [[API_wipe#Notes|wipe(t)]]  would be more effective.
--[[User:MichaelLundRasmussen|MichaelLundRasmussen]] ([[User talk:MichaelLundRasmussen|talk]]) 13:10, December 30, 2009 (UTC)
Anonymous user