garrysmod icon indicating copy to clipboard operation
garrysmod copied to clipboard

Change pairs to ipairs

Open ceifa opened this issue 4 years ago • 4 comments

A micro optimization to save some nanosecs of cpu

ceifa avatar Jul 23 '21 20:07 ceifa

It's better but not faster as it will not jit compile and outside or jit compiled mode, pairs is faster than ipairs

ExtReMLapin avatar Jul 27 '21 12:07 ExtReMLapin

This will be faster in x86_64's JIT.

Kefta avatar Jul 27 '21 12:07 Kefta

It's better but not faster as it will not jit compile and outside or jit compiled mode, pairs is faster than ipairs

Didn't know that, does it have a reason to jit compile pairs but not ipairs?

ceifa avatar Jul 27 '21 13:07 ceifa

It wouldn't compile in both cases. But pairs apprently is faster in non-JITted code. The possible reason is the implementation, I didn't look deeper but I assume this.

GitSparTV avatar Jul 27 '21 13:07 GitSparTV

Superseded by https://github.com/Facepunch/garrysmod/pull/1609

robotboy655 avatar Jan 16 '23 17:01 robotboy655