Comparison

util/jid.lua @ 12768:6e3aa3995eab

util.jid: Remove redundant check from split() (micro-optimization?)
author Matthew Wild <mwild1@gmail.com>
date Tue, 11 Oct 2022 13:33:19 +0100
parent 12605:053417068957
child 12769:27e1d4354274
comparison
equal deleted inserted replaced
12767:3b75943fa5c1 12768:6e3aa3995eab
33 33
34 local function split(jid) 34 local function split(jid)
35 if jid == nil then return; end 35 if jid == nil then return; end
36 local node, nodepos = match(jid, "^([^@/]+)@()"); 36 local node, nodepos = match(jid, "^([^@/]+)@()");
37 local host, hostpos = match(jid, "^([^@/]+)()", nodepos); 37 local host, hostpos = match(jid, "^([^@/]+)()", nodepos);
38 if node ~= nil and host == nil then return nil, nil, nil; end 38 local resource = host and match(jid, "^/(.+)$", hostpos);
39 local resource = match(jid, "^/(.+)$", hostpos);
40 if (host == nil) or ((resource == nil) and #jid >= hostpos) then return nil, nil, nil; end 39 if (host == nil) or ((resource == nil) and #jid >= hostpos) then return nil, nil, nil; end
41 return node, host, resource; 40 return node, host, resource;
42 end 41 end
43 42
44 local function bare(jid) 43 local function bare(jid)