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

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The separator between a module name and a symbol name in a fully qualified name.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static String
    Symbol names can be fully qualified (i.e.
    static String
    Just returns the actual symbol name in unqualified form (i.e.
    static boolean
    hasModuleName(String symbolName, String moduleName)
    THE allocation-free form of moduleName.equals(getModuleNameIfPresent(symbolName)) for a QUALIFIED name: is the text before the first separator exactly moduleName? Always false for an unqualified name, so a caller that must treat an unqualified name differently tests isQualifiedName(String) first.
    static boolean
    isQualifiedName(String symbolName)
     
    static String
    makeFullyQualifiedName(String scopeName, String symbolName)
    Convert a scope name (module name) and a symbol name into a fully qualified symbol name.
  • Field Details

    • MODULE_SEPARATOR

      static final String MODULE_SEPARATOR
      The separator between a module name and a symbol name in a fully qualified name.
      See Also:
  • Method Details

    • getModuleNameIfPresent

      static String getModuleNameIfPresent(String symbolName)
      Symbol names can be fully qualified (i.e. with the module name) or just a name. This method returns the module name if present or "" if not.
    • hasModuleName

      static boolean hasModuleName(String symbolName, String moduleName)
      THE allocation-free form of moduleName.equals(getModuleNameIfPresent(symbolName)) for a QUALIFIED name: is the text before the first separator exactly moduleName? Always false for an unqualified name, so a caller that must treat an unqualified name differently tests isQualifiedName(String) first.
    • getUnqualifiedName

      static String getUnqualifiedName(String symbolName)
      Just returns the actual symbol name in unqualified form (i.e. no module name).
    • isQualifiedName

      static boolean isQualifiedName(String symbolName)
    • makeFullyQualifiedName

      static String makeFullyQualifiedName(String scopeName, String symbolName)
      Convert a scope name (module name) and a symbol name into a fully qualified symbol name.