jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/341355 )

Change subject: Speed up PHP mw.ustring.gcodepoint
......................................................................


Speed up PHP mw.ustring.gcodepoint

It seems to be over 200 times faster to iterate over the array instead
of shifting off the front.

Change-Id: Id29a4739ae2bd5dac4197e110ea73f74794e6d9f
---
M engines/LuaCommon/lualib/mw.ustring.lua
1 file changed, 6 insertions(+), 1 deletion(-)

Approvals:
  Tim Starling: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/engines/LuaCommon/lualib/mw.ustring.lua 
b/engines/LuaCommon/lualib/mw.ustring.lua
index 33e5e39..0825a73 100644
--- a/engines/LuaCommon/lualib/mw.ustring.lua
+++ b/engines/LuaCommon/lualib/mw.ustring.lua
@@ -29,8 +29,13 @@
        checkType( 'gcodepoint', 2, i, 'number', true )
        checkType( 'gcodepoint', 3, j, 'number', true )
        local cp = gcodepoint_init( s, i, j or -1 )
+       local pos, len = 1, #cp
        return function ()
-               return table.remove( cp, 1 )
+               if pos <= len then
+                       local tmp = cp[pos]
+                       pos = pos + 1
+                       return tmp
+               end
        end
 end
 

-- 
To view, visit https://gerrit.wikimedia.org/r/341355
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id29a4739ae2bd5dac4197e110ea73f74794e6d9f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to