Logger
#9
The HandleConsoleDBShow could use some refactoring:
- Lines 178 - 181 can be replaced with a simple "split_count = #Split"
- There's no need to check array boundaries in Lua - all elements outside the boundaries are implicitly "nil". It's much better to check "if (Split[3])" than "if (#Split > 2)", because the first condition does one table lookup, while the latter does an element count (which is an O(N) operation where N is the total number of elements in the array).
- I think the limit should default to a reasonable number, rather than "unlimited" when no param is given. You don't want the entire history of a year-old server spewed out when the admin forgets the limit parameter Smile

Therefore it should be possible to replace lines 178 - 188 with a single line:
ret_rows_count = " LIMIT " .. math.floor(tonumber(Split[3]) or 30)
(tonumber works on everything you throw at it, returning nil when it's not a recognizable number, the "or" operator then makes sure that if no number is returned, 30 (the default limit) is used. Also note that the semicolon is not needed for SQL commands, unless you're executing multiple commands with a single execute() call)
Reply
Thanks given by:


Messages In This Thread
Logger - by DrMasik - 08-18-2015, 05:59 AM
RE: Logger - by NiLSPACE - 08-18-2015, 06:15 AM
RE: Logger - by DrMasik - 08-18-2015, 06:18 AM
RE: Logger - by xoft - 08-18-2015, 04:26 PM
RE: Logger - by DrMasik - 08-19-2015, 04:58 AM
RE: Logger - by DrMasik - 08-19-2015, 07:31 AM
RE: Logger - by xoft - 08-19-2015, 04:32 PM
RE: Logger - by DrMasik - 08-19-2015, 08:20 PM
RE: Logger - by xoft - 08-20-2015, 01:01 AM
RE: Logger - by DrMasik - 08-20-2015, 01:56 AM
RE: Logger - by xoft - 08-20-2015, 01:04 AM
RE: Logger - by DrMasik - 08-20-2015, 02:46 AM
RE: Logger - by DrMasik - 08-20-2015, 05:59 PM
RE: Logger - by NiLSPACE - 08-20-2015, 06:12 PM
RE: Logger - by DrMasik - 08-20-2015, 06:23 PM
RE: Logger - by NiLSPACE - 08-20-2015, 06:26 PM
RE: Logger - by DrMasik - 08-20-2015, 06:36 PM
RE: Logger - by NiLSPACE - 08-20-2015, 06:47 PM
RE: Logger - by DrMasik - 08-20-2015, 06:51 PM
RE: Logger - by NiLSPACE - 08-20-2015, 07:18 PM
RE: Logger - by DrMasik - 08-21-2015, 05:57 AM



Users browsing this thread: 1 Guest(s)