Software /
code /
prosody
Comparison
net/server_epoll.lua @ 11698:9a2a98621c73
net.server_epoll: Optimize concatenation of exactly 2 buffer chunks
Saves a function call. I forget if I measured this kind of thing but
IIRC infix concatenation is faster than a function call up to some
number of items, but let's stop at 2 here.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 16 Jul 2021 15:40:08 +0200 |
parent | 11697:6c3d8aa3bbd9 |
child | 11699:1275dad71afd |
comparison
equal
deleted
inserted
replaced
11697:6c3d8aa3bbd9 | 11698:9a2a98621c73 |
---|---|
471 self:onconnect(); | 471 self:onconnect(); |
472 if not self.conn then return; end -- could have been closed in onconnect | 472 if not self.conn then return; end -- could have been closed in onconnect |
473 local buffer = self.writebuffer; | 473 local buffer = self.writebuffer; |
474 local data = buffer or ""; | 474 local data = buffer or ""; |
475 if type(buffer) == "table" then | 475 if type(buffer) == "table" then |
476 if buffer[2] then | 476 if buffer[3] then |
477 data = t_concat(data); | 477 data = t_concat(data); |
478 elseif buffer[2] then | |
479 data = buffer[1] .. buffer[2]; | |
478 else | 480 else |
479 data = buffer[1] or ""; | 481 data = buffer[1] or ""; |
480 end | 482 end |
481 end | 483 end |
482 local ok, err, partial = self.conn:send(data); | 484 local ok, err, partial = self.conn:send(data); |