lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I only looked over the script quickly so forgive me if I misunderstood
anything or my advice is incorrect.

Personally I tend to avoid using table.insert in favor of
    tab[#tab + 1] = item
or keeping an explicit counter, but that probably doesn't matter much
except in tight loops.

Using string.match instead of string.find might be of some help when all
you want is captured data is probably a good idea (it saves you from
needing to dump the indices you don't care about into dummy variables).

You don't need to check whether string.find matches before doing the
capture since if the find is going to fail then so will the capture (which
you can tell because you will get nil back). Doing this would let you get
rid of the 'match' variable since you could just check y, m, and d

Also, since you only set 'match' when your string.find succeeds and you
always set y, m, and d in that case and you always break immediately you
don't need the extra test of 'match' since you can insert the results into
imagedates in the inner loop before breaking.

Generally you would be better served using a keyed table for keeping
distinct data rather than an array. So instead of inserting dates into
distdates with integer keys, use the dates as the keys and set the values
to true. This means that you get duplicate checking for free, since you
can't have a key more than once, it means you don't need to check for the
existance of the key already since setting it to true an extra time
doesn't hurt you, and it doesn't materially change the loop that is needed
to use the dates when you are done.

Other than that my only comment is Use Locals.