Software / code / prosody-modules
Comparison
mod_http_oauth2/mod_http_oauth2.lua @ 6320:ebcf612da2b1
mod_http_oauth2: Use numeric for loop instead of ipairs
Pedantic attempted optimization, reducing function calls.
I didn't even measure, only vaguely recall that this is faster in PUC Lua.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 03 Jul 2025 12:14:53 +0200 |
| parent | 6319:63ef69b2f046 |
| child | 6321:e174e12549e1 |
comparison
equal
deleted
inserted
replaced
| 6319:63ef69b2f046 | 6320:ebcf612da2b1 |
|---|---|
| 27 return t[k]; | 27 return t[k]; |
| 28 end | 28 end |
| 29 end | 29 end |
| 30 | 30 |
| 31 local function array_contains(haystack, needle) | 31 local function array_contains(haystack, needle) |
| 32 for _, item in ipairs(haystack) do | 32 for i = 1, #haystack do |
| 33 if item == needle then | 33 if haystack[i] == needle then |
| 34 return true | 34 return true |
| 35 end | 35 end |
| 36 end | 36 end |
| 37 return false | 37 return false |
| 38 end | 38 end |