Skip to content

string length performance trap #33712

@JeffBezanson

Description

@JeffBezanson

I recently saw some code that used while i <= length(s) where s is a String. This can happen e.g. when porting code that assumes all data is ASCII. Obviously one answer is "don't do that", but it would be nice if we could handle this better. Two ideas:

  • Tell LLVM that length(::String) is pure and can be hoisted out of loops.
  • Use the top bit of the length field to store whether a string is ASCII, speeding up length and isascii in that case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions