Lexer in D

Namespace rswhite4 at googlemail.com
Sat Mar 2 06:32:44 PST 2013


I sorted both, types and keywords, alphabetical and wrote my own 
'canFind':

bool canFind(const size_t size)(ref const string[size] values, 
string value) pure nothrow {
	if (value[0] < 'm' || value[0] == '_') {
		foreach (string _val; values) {
			if (_val == value) return true;
		}
	} else {
		foreach_reverse (string _val; values) {
			if (_val == value) return true;
		}
	}
	
	return false;
}

That brings ~20 msecs, so I have ~280 mesecs instead of ~ 300. 
But it isn't perfect.


More information about the Digitalmars-d-learn mailing list