Faster allocate_string()

new topic     » topic index » view thread      » older message » newer message

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

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu