From b67b20eb15224eebcab7d17068a533f604bbf51e Mon Sep 17 00:00:00 2001 From: Douglas Bates Date: Mon, 1 Dec 2014 15:16:51 -0600 Subject: [PATCH] Memory map the document file as an array of bytes then split. --- src/readers.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/readers.jl b/src/readers.jl index 326229b..e2429fd 100644 --- a/src/readers.jl +++ b/src/readers.jl @@ -1,5 +1,8 @@ function read_noweb(document) - doctext = readall(open(document)) + #doctext = readall(open(document)) + lines = split(bytestring(open(document) do io + mmap_array(Uint8,(filesize(document),),io) + end), "\n") #doctext = document #Replace with file... codestart = r"^<<(.*?)>>=" codeend = r"^@(\s*)$" @@ -14,8 +17,8 @@ function read_noweb(document) options = Dict() optionstring = "" parsed = Dict[] - for (lineno, line) in enumerate(split(doctext, "\n")) - + for lineno in 1:length(lines) + line = lines[lineno] if ismatch(codestart, line) && state=="doc" state = "code" m = match(codestart, line)