25 May 00:53
Vim script optimization tips
richard emberson <richard.emberson <at> gmail.com>
2012-05-24 22:53:52 GMT
2012-05-24 22:53:52 GMT
Is there a resource concerning the writing of optimized
Vim scripts (both memory usage and performance).
For instance:
Should variable name be short?
Should spaces not be put between tokens?
"value=" . value
a + b
let cnt = cnt + 1
versus
"value=".value
a+b
let cnt +=1
Since Vim does not have a switch/case statement (??)
are a chain of if-elseifs the best one can do.
In a function is accessing a parameter
func Foo(p)
let x = a:p "
endfunc
slower than accessing a local that has been set to the parameter
(ignoring the cost of setting the local).
func Foo(p)
let p = a:p
let x = p " faster or slower than x = a:p
endfunc
In many scripts I've seen, it is the short version key words,
options, etc are used, e.g,
func rather than function
Thanks
(Continue reading)
RSS Feed