table.quickUniqueName

Jan M.J. Storms jan at storms.org
Mon Oct 7 01:56:24 PDT 2002


This is my quick version of table.uniquename:

on quickUniqueName ( prefix, tableAdr, places=nil ) { «returns the
address of a unique object in the database
	local (name, ct = sizeOf (tableAdr^), adr);
	if places == nil {
		loop {
			adr = @tableAdr^.[prefix + ++ct];
			if not defined (adr^) {
				return (adr)}}}
	else {
		loop {
			adr = @tableAdr^.[prefix + string.padWithZeros (++ct, places)];
			if not defined (adr^) {
				return (adr)}}}}

Note that it behaves differently from the original, but it does the job
many times faster. The difference is that there are situations in which
it will waste numbers. But we have an infinity (2,147,483,647) of those
anyway.

HYLI,

Jan Storms

(HYLI = hope you like it)




More information about the Frontier-Users mailing list