aboutsummaryrefslogtreecommitdiff
path: root/testes/gc.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-04-11 11:29:16 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-04-11 11:29:16 -0300
commitb0810c51c3f075cc8a309bfb3c1714ac42b0f020 (patch)
tree8d9e58246f442f1fbec8bb14ffebb77bd40c3564 /testes/gc.lua
parenta93e0144479f1eb0ac19b8c31862f4cbc2fbe1c4 (diff)
downloadlua-b0810c51c3f075cc8a309bfb3c1714ac42b0f020.tar.gz
lua-b0810c51c3f075cc8a309bfb3c1714ac42b0f020.tar.bz2
lua-b0810c51c3f075cc8a309bfb3c1714ac42b0f020.zip
Small optimizations in 'string.gsub'
Avoid creating extra strings when possible: - avoid creating new resulting string when subject was not modified (instead, return the subject itself); - avoid creating strings representing the captured substrings when handling replacements like '%1' (instead, add the substring directly to the buffer).
Diffstat (limited to 'testes/gc.lua')
-rw-r--r--testes/gc.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/testes/gc.lua b/testes/gc.lua
index 91e78a48..6d24e0d8 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -113,7 +113,7 @@ do
113 contCreate = 0 113 contCreate = 0
114 while contCreate <= limit do 114 while contCreate <= limit do
115 a = contCreate .. "b"; 115 a = contCreate .. "b";
116 a = string.gsub(a, '(%d%d*)', string.upper) 116 a = string.gsub(a, '(%d%d*)', "%1 %1")
117 a = "a" 117 a = "a"
118 contCreate = contCreate+1 118 contCreate = contCreate+1
119 end 119 end