Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit efficient code for switch over strings #11937

Merged
merged 1 commit into from
Aug 24, 2021

Commits on Aug 18, 2021

  1. Emit efficient code for switch over strings

    The pattern matcher will now emit `Match` with `String` scrutinee as
    well as the existing `Int` scrutinee. The JVM backend handles this case
    by emitting bytecode that switches on the String's `hashCode` (this
    matches what Java does). The SJS already handles `String` matches.
    
    The approach is similar to scala/scala#8451 (see scala/bug#11740 too),
    except that instead of doing a transformation on the AST, we just emit the
    right bytecode straight away. This is desirable since it means that
    Scala.js (and any other backend) can choose their own optimised strategy
    for compiling a match on strings.
    
    Fixes scala#11923
    harpocrates committed Aug 18, 2021
    Configuration menu
    Copy the full SHA
    3d8fa54 View commit details
    Browse the repository at this point in the history