Skip to content

Eliminate uses of SameString and transition to case-sensitive string comparisons #9183

@amirroth

Description

@amirroth

SameString, currently a pass-through to ObjexxFCL::equali performs a case-insensitive string comparison. There are currently 2400 calls to SameString in EnergyPlus. A quick scan of these calls shows that there are three primary idioms:

  • Use of SameString in an if-then ladder to essentially convert a string to an enumeration (overlaps with issue #9181). This idiom should be converted to use getEnumerationValue whose arguments are a std::array of upper-cased string_views corresponding to the names of the enumeration values and an upper-cased (via MakeUpperCase) version of the search string. (Search the code for getEnumerationValue to see some examples). In this implementation, the search string is upper-cased only once rather than once per comparison and the list of valid strings is not explicitly upper-cased at all.
  • Use of SameString instead of an existing enumeration in simulation logic. These should be converted to switch-case idioms using enumerations.
  • Use of SameString to match object names. A good general rule is that every string in a program should be upper-cased at most once. This means that lists of objects names that are to be searched should be stored in upper-case and searches should be case-sensitive, i.e., using ==.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NotIDDChangeCode does not impact IDD (can be merged after IO freeze)RefactoringIncludes code changes that don't change the functionality of the program, just perform refactoring

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions