Faster allocate_string()
- Posted by Larry Miller <larrymiller at sasktel.net> Jul 06, 2005
- 527 views
This an improved version of allocate_string(). Performance improvement is small, on the order of 20%, but might be of interest to some.
global function allocate_string(sequence s) atom addr addr=machine_func(M_ALLOC, length(s) + 1) if addr then poke(addr, s) poke(addr + length(s), 0) end if return addr end function
The use of machine_func(), rather than allocate(), saves a function call and the type check used in allocate(). The type check is unnecessary here as the length of a sequence is guaranteed to be a positive integer. I fully recognize that the use of machine_func() is not normally justifiable in an application, but a low level include file is another matter. Larry Miller