major non-jit lua speedup

This commit is contained in:
FourierTransformer 2016-03-19 01:17:32 -05:00
parent 48fbb20d46
commit c58bd79a24

View File

@ -47,20 +47,24 @@ end
-- finds the end of an escape sequence -- finds the end of an escape sequence
local function findClosingQuote(i, inputLength, inputString, quote, doubleQuoteEscape) local function findClosingQuote(i, inputLength, inputString, quote, doubleQuoteEscape)
-- local doubleQuoteEscape = doubleQuoteEscape -- local doubleQuoteEscape = doubleQuoteEscape
local currentChar, nextChar = string.byte(inputString, i), nil
while i <= inputLength do while i <= inputLength do
-- print(i) -- print(i)
local currentChar = string.byte(inputString, i) nextChar = string.byte(inputString, i+1)
local nextChar = string.byte(inputString, i+1)
-- this one deals with " double quotes that are escaped "" within single quotes " -- this one deals with " double quotes that are escaped "" within single quotes "
-- these should be turned into a single quote at the end of the field -- these should be turned into a single quote at the end of the field
if currentChar == quote and nextChar == quote then if currentChar == quote and nextChar == quote then
doubleQuoteEscape = true doubleQuoteEscape = true
i = i + 2 i = i + 2
currentChar = string.byte(inputString, i)
-- identifies the escape toggle -- identifies the escape toggle
elseif currentChar == quote and nextChar ~= quote then elseif currentChar == quote and nextChar ~= quote then
return i-1, doubleQuoteEscape return i-1, doubleQuoteEscape
else else
i = i + 1 i = i + 1
currentChar = nextChar
end end
end end
end end
@ -167,7 +171,7 @@ function ftcsv.parse(inputFile, delimiter, options)
local i = 1 local i = 1
-- keep track of my chars! -- keep track of my chars!
local currentChar, nextChar = string.byte(inputString, i), string.byte(inputString, i+1) local currentChar, nextChar = string.byte(inputString, i), nil
while i <= inputLength do while i <= inputLength do
-- go by two chars at a time! -- go by two chars at a time!