Skip to content

Instantly share code, notes, and snippets.

@JakobOvrum
Created November 19, 2010 23:46
Show Gist options
  • Save JakobOvrum/707429 to your computer and use it in GitHub Desktop.
Save JakobOvrum/707429 to your computer and use it in GitHub Desktop.
Concatify: less garbage, less copying, better complexity
if data then
local where = {}
local k, v = next(data, nil)
if k then
insert(where, concat{k, '=', sql_tostring(v)})
for k, v in next, data, k do
insert(where, concat{' AND ', k, '=', sql_tostring(v)})
end
end
query = concat{query, ' WHERE ', concat(where)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment