Mercurial > prosody-modules
comparison mod_http_oauth2/mod_http_oauth2.lua @ 5276:67777cb7353d
mod_http_oauth2: Pedantic optimization
Checking the length of the string seems like 30% more expensive than
comparing it with the empty string (by reference, probably).
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 26 Mar 2023 14:37:42 +0200 |
| parents | 40be37652d70 |
| children | a1055024b94e |
comparison
equal
deleted
inserted
replaced
| 5275:3e30799deec2 | 5276:67777cb7353d |
|---|---|
| 333 -- Our strategy here is to preserve the original query string (containing the authz request), and | 333 -- Our strategy here is to preserve the original query string (containing the authz request), and |
| 334 -- encode the rest of the flow in form POSTs. | 334 -- encode the rest of the flow in form POSTs. |
| 335 local function get_auth_state(request) | 335 local function get_auth_state(request) |
| 336 local form = request.method == "POST" | 336 local form = request.method == "POST" |
| 337 and request.body | 337 and request.body |
| 338 and #request.body > 0 | 338 and request.body ~= "" |
| 339 and request.headers.content_type == "application/x-www-form-urlencoded" | 339 and request.headers.content_type == "application/x-www-form-urlencoded" |
| 340 and http.formdecode(request.body); | 340 and http.formdecode(request.body); |
| 341 | 341 |
| 342 if not form then return {}; end | 342 if not form then return {}; end |
| 343 | 343 |
