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 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.
    • 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.