[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.len(str) vs str:len()
- From: Mason Mackaman <masondeanm@...>
- Date: Thu, 7 Aug 2014 12:46:35 -0500
I’m still curious about all this, but this whole time I had forgotten about ‘#str’, which I just tested and is much faster than all the other ways for whatever reason.
On Aug 7, 2014, at 12:35 PM, Mason Mackaman <masondeanm@aol.com> wrote:
> So does some equivalent of "local getmetatable('').__index=_ENV.string” execute before the program starts?
> On Aug 7, 2014, at 12:22 PM, Mason Mackaman <masondeanm@aol.com> wrote:
>
>> This statement is on hold while I digest Elias’ post. I hadn’t seen it when I said that.
>> On Aug 7, 2014, at 12:12 PM, Mason Mackaman <masondeanm@aol.com> wrote:
>>
>>> AHHH! but I thought the only thing the metatable did was tell Lua to get _ENV.string whenever you try to index ’str’!? Sorry if I’m being annoying, I’m just trying to understand.
>>> On Aug 7, 2014, at 11:52 AM, Coda Highland <chighland@gmail.com> wrote:
>>>
>>>> On Thu, Aug 7, 2014 at 9:47 AM, Mason Mackaman <masondeanm@aol.com> wrote:
>>>>> I think the reason I’m still confused is I’m not understanding how this works. I figured when you do str:len(), you still have to access the global ‘string’ table, because that’s what the __index metamethod is for ‘str’s metatable. In which case it would be more work. Are you saying str:len() retrieves the ‘len' function without having to get _ENV.table?
>>>>
>>>> That's exactly what's being said here. Going from str to str's
>>>> metatable doesn't involve any external lookups at all.
>>>>
>>>> /s/ Adam
>>>>
>>>
>>>
>>
>>
>
>
- References:
- string.len(str) vs str:len(), Mason Mackaman
- Re: string.len(str) vs str:len(), Thiago L.
- Re: string.len(str) vs str:len(), Mason Mackaman
- Re: string.len(str) vs str:len(), Thiago L.
- Re: string.len(str) vs str:len(), Mason Mackaman
- Re: string.len(str) vs str:len(), Coda Highland
- Re: string.len(str) vs str:len(), Thiago L.
- Re: string.len(str) vs str:len(), Mason Mackaman
- Re: string.len(str) vs str:len(), Coda Highland
- Re: string.len(str) vs str:len(), Mason Mackaman
- Re: string.len(str) vs str:len(), Mason Mackaman
- Re: string.len(str) vs str:len(), Mason Mackaman