Use local variable to speed up access to `input'

This commit is contained in:
Jocelyn Fiat
2012-03-19 10:12:06 +01:00
parent 9f1940c46d
commit b05ff01262

View File

@@ -99,14 +99,17 @@ feature {NONE} -- Parser
read_chunk_data read_chunk_data
require require
last_chunk_size > 0 last_chunk_size > 0
local
l_input: like input
do do
input.read_string (last_chunk_size) l_input := input
last_chunk := input.last_string l_input.read_string (last_chunk_size)
last_chunk := l_input.last_string
-- read CRLF -- read CRLF
input.read_character l_input.read_character
if input.last_character = '%R' then if l_input.last_character = '%R' then
input.read_character l_input.read_character
end end
ensure ensure
last_chunk_attached: attached last_chunk as el_last_chunk last_chunk_attached: attached last_chunk as el_last_chunk
@@ -120,24 +123,26 @@ feature {NONE} -- Parser
eol : BOOLEAN eol : BOOLEAN
c: CHARACTER c: CHARACTER
hex : HEXADECIMAL_STRING_TO_INTEGER_CONVERTER hex : HEXADECIMAL_STRING_TO_INTEGER_CONVERTER
l_input: like input
do do
l_input := input
from from
input.read_character l_input.read_character
until until
eol eol
loop loop
c := input.last_character c := l_input.last_character
inspect c inspect c
when '%R' then when '%R' then
-- We are in the end of the line, we need to read the next character to start the next line. -- We are in the end of the line, we need to read the next character to start the next line.
eol := True eol := True
input.read_character l_input.read_character
when ';' then when ';' then
-- We are in an extension chunk data -- We are in an extension chunk data
read_extension_chunk read_extension_chunk
else else
tmp_hex_chunk_size.append_character (c) tmp_hex_chunk_size.append_character (c)
input.read_character l_input.read_character
end end
end end
if tmp_hex_chunk_size.same_string ("0") then if tmp_hex_chunk_size.same_string ("0") then
@@ -155,40 +160,46 @@ feature {NONE} -- Parser
end end
read_extension_chunk read_extension_chunk
local
l_input: like input
do do
l_input := input
debug debug
print (" Reading extension chunk ") print (" Reading extension chunk ")
end end
from from
input.read_character l_input.read_character
until until
input.last_character = '%R' l_input.last_character = '%R'
loop loop
debug debug
print (input.last_character) print (l_input.last_character)
end end
input.read_character l_input.read_character
end end
end end
read_trailer read_trailer
local
l_input: like input
do do
if not input.end_of_input then l_input := input
if not l_input.end_of_input then
debug debug
print (" Reading trailer ") print (" Reading trailer ")
end end
from from
input.read_character l_input.read_character
until until
input.last_character = '%R' l_input.last_character = '%R'
loop loop
debug debug
print (input.last_character) print (l_input.last_character)
end end
input.read_character l_input.read_character
end end
-- read the LF -- read the LF
input.read_character l_input.read_character
end end
end end