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

Optimizing "constant_string".Length #5310

Closed
jamesqo opened this issue Mar 10, 2016 · 1 comment
Closed

Optimizing "constant_string".Length #5310

jamesqo opened this issue Mar 10, 2016 · 1 comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions optimization tenet-performance Performance related issue
Milestone

Comments

@jamesqo
Copy link
Contributor

jamesqo commented Mar 10, 2016

Lots of times for readability I use "constant_string".Length instead of 15 in my code. For example:

string TextAfterFoo(string s) =>
    s.Substring(s.IndexOf("Foo") + "Foo".Length); // a lot more readable than `3`

It would be nice if RyuJIT could optimize this as a JIT-time constant, so a string wouldn't have to actually be loaded and called Length on.

category:cq
theme:basic-cq
skill-level:intermediate
cost:medium

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@msftgits msftgits added this to the Future milestone Jan 30, 2020
@EgorBo
Copy link
Member

EgorBo commented Mar 4, 2020

Implemented in #1378

@EgorBo EgorBo closed this as completed Mar 4, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions optimization tenet-performance Performance related issue
Projects
None yet
Development

No branches or pull requests

3 participants