Interface INaming
public interface INaming
Used to assist with determining the naming of symbol names.
These are on the hottest path in symbol resolution - a JFR profile of phases 0-2 put
getUnqualifiedName and getModuleNameIfPresent as the two topmost EK9
frames, with 16% of all samples inside java.util.regex. The cause was
String.split("::"): String.split only takes its no-regex fastpath for a
SINGLE character, so a two-character separator compiles a fresh Pattern
on every call. indexOf/substring is 9x faster and allocates no array.
Keep these regex-free. They are called for essentially every name lookup in the compiler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe separator between a module name and a symbol name in a fully qualified name. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic StringgetModuleNameIfPresent(String symbolName) Symbol names can be fully qualified (i.e.static StringgetUnqualifiedName(String symbolName) Just returns the actual symbol name in unqualified form (i.e.static booleanhasModuleName(String symbolName, String moduleName) THE allocation-free form ofmoduleName.equals(getModuleNameIfPresent(symbolName))for a QUALIFIED name: is the text before the first separator exactlymoduleName? Always false for an unqualified name, so a caller that must treat an unqualified name differently testsisQualifiedName(String)first.static booleanisQualifiedName(String symbolName) static StringmakeFullyQualifiedName(String scopeName, String symbolName) Convert a scope name (module name) and a symbol name into a fully qualified symbol name.
-
Field Details
-
MODULE_SEPARATOR
The separator between a module name and a symbol name in a fully qualified name.- See Also:
-
-
Method Details
-
getModuleNameIfPresent
-
hasModuleName
THE allocation-free form ofmoduleName.equals(getModuleNameIfPresent(symbolName))for a QUALIFIED name: is the text before the first separator exactlymoduleName? Always false for an unqualified name, so a caller that must treat an unqualified name differently testsisQualifiedName(String)first. -
getUnqualifiedName
-
isQualifiedName
-
makeFullyQualifiedName
-