Thursday, November 18, 2010 at 12:01 AM.

system.verbs.builtins.tcp.equalNames

on equalNames (name1, name2) { //return true if they're the same node on the net
	<<Changes
		<<11/17/10; 9:32:14 PM by DW
			<<An ancient routine that is called a lot and can be made much faster. 
				<<First step, compare the names before doing any normalizing. If they're equal, just return true without any normalizing. 
				<<Second step, use tcp.dns.getdottedid, instead of cooking our own conversion. Big advantage, we get to use its cache in system.temp table. :-)
	bundle { //shortcut all the fancy stuff, 11/17/10 by DW
		if string.lower (name1) == string.lower (name2) {
			return (true)}};
	on normalizeName (name) { //turn the name into a dotted id
		try {
			local (i, seg);
			for i = 1 to 4 {
				seg = number (string.nthField (name, '.', i));
				if seg > 255 {
					return (tcp.addressDecode (tcp.nameToAddress (name)))}};
			return (name)} //it's already a dotted id
		else {
			return (tcp.dns.getdottedid (name))}};
			<<name = tcp.nameToAddress (name)
			<<return (tcp.addressDecode (name))
	name1 = normalizeName (name1);
	name2 = normalizeName (name2);
	return (name1 == name2)};
bundle { //test code
	dialog.alert (equalNames ("www.userland.com", "206.204.24.11"));
	dialog.alert (equalNames ("www.scripting.com", "206.204.24.4"))}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.