> > > if you put the code in a function, it will be a fair bit faster > > > since global variable access is slower than local variable access. > Actually, it increases performance by ~15%. That is too be expected. Fast load and save opcodes are not generated for globals.