Wednesday, December 30, 2009

Accelerate formatting of 4000 lines into 4000 new

Hi Christian,

I am using one method to take data present in each line of a 4000
lines' file but I would like your advise to accelerate process cause
it takes 10 seconds.

First I am a pattern that recognize some data in each parsed line,
this is it :

let g:patternItemLine = '^.*item foo="\([^"]\+\)\/\(\w\+\)"\s\+foobar
\s*="\([^"]\+\)"\s\+barfoo\s*="\([^"]\+\)"\s\+Type\s*="\([^"]\+\)".*$'

Then I send a g command in order to make the job only on <item lines
in a file that contains other lines'type :
silent g/<item\s/call PROCESS(getline(line('.')))


func! PROCESS(line)

let l:lineArranged = substitute(a:line, g:patternItemLine, '{ "\2",
\3, 0, FALSE, ITEM_\5, OPC_READABLE|OPC_WRITEABLE, \4, USER_FRONTAL|
USER_MAINTENANCE, 0, 0, 0, 0, "\1" },', "")
d)
let g:newContent .= l:lineArranged . "\n"
return ''
endfunc

This call of PROCESS take 10 seconds cause I am analysing the current
line, substituting using 5 backref and concat to a newContent var.

Have you got some idea to accelerate process.
Thank you


--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment