aboutsummaryrefslogtreecommitdiffstats
path: root/net/server_epoll.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-07-16 15:40:08 +0200
committerKim Alvefur <zash@zash.se>2021-07-16 15:40:08 +0200
commit50bd7b79ea2c7c904661057c751c0e9df2c3eb91 (patch)
tree127991402d4e9f902dfcde796b05a840f7f4353a /net/server_epoll.lua
parent56fef6867fc30100b77be1146e4e70bf25970e6b (diff)
downloadprosody-50bd7b79ea2c7c904661057c751c0e9df2c3eb91.tar.gz
prosody-50bd7b79ea2c7c904661057c751c0e9df2c3eb91.zip
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.
Diffstat (limited to 'net/server_epoll.lua')
-rw-r--r--net/server_epoll.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index 8db18930..b2f49f7c 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -473,8 +473,10 @@ function interface:onwritable()
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