lua-users home
lua-l archive

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

Theodor-Iulian Ciobanu wrote:
> From what I understand, this was in previous versions and has been removed.
> I had no idea of that. I'll stick with gsub then, as using metatables would
> slow me down a bit (more code around the gsub call).

Remember the two rules of optimising your code:

1. Do not optimise your code.
2. (for experts only) Do not optimise your code yet.

You may find the metatable trick is plenty fast enough --- if you really are
doing time-critical processing, then you won't be able to tell for sure until
you measure it. Intuition is frequently wrong.

That said, you may find this idiom useful:

local string_gsub = string.gsub


a = string_gsub(s, p, r)

It saves two table lookups per call.

> PS: I have auto-wrapping set at 70 characters, which kicks in when writing
> a mail and I never noticed the mails arriving unwrapped on the list until
> mentioned. I'll check my settings.

Still not working, I'm afraid.

╭─┈David Given┈──McQ─╮ "A line dancer near a graduated cylinder, the
│┈┈┈┈┈│ blithe spirit inside some wheelbarrow, and a tomato
│┈(┈│ are what made America great!" --- received via spam

Attachment: signature.asc
Description: OpenPGP digital signature