Software /
code /
prosody
Changeset
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 |
parents | 11697:6c3d8aa3bbd9 |
children | 11699:1275dad71afd |
files | net/server_epoll.lua |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_epoll.lua Fri Jul 16 15:38:38 2021 +0200 +++ b/net/server_epoll.lua Fri Jul 16 15:40:08 2021 +0200 @@ -473,8 +473,10 @@ local buffer = self.writebuffer; local data = buffer or ""; if type(buffer) == "table" then - if buffer[2] then + if buffer[3] then data = t_concat(data); + elseif buffer[2] then + data = buffer[1] .. buffer[2]; else data = buffer[1] or ""; end