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

Optimize the loop processing of URL decoding #110235

Open
shane-zfx opened this issue Jun 27, 2024 · 1 comment
Open

Optimize the loop processing of URL decoding #110235

shane-zfx opened this issue Jun 27, 2024 · 1 comment
Labels
:Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team

Comments

@shane-zfx
Copy link

shane-zfx commented Jun 27, 2024

Hey guys, I saw the following content when I was studying the es source code.

private static boolean decodingNeeded(String s, int size, boolean plusAsSpace) {
boolean decodingNeeded = false;
for (int i = 0; i < size; i++) {
final char c = s.charAt(i);
if (c == '%') {
i++; // We can skip at least one char, e.g. `%%'.
decodingNeeded = true;
} else if (plusAsSpace && c == '+') {
decodingNeeded = true;
}
}
return decodingNeeded;
}

I think this method can be optimized in terms of performance efficiency. e.g.

for (int i = 0; i < size; i++) {
    final char c = s.charAt(i);
    if (c == '%' || (plusAsSpace && c == '+')) {
         return true;
    } 
}

If it's necessary,I'll submit a PR later

@elasticsearchmachine elasticsearchmachine added the needs:triage Requires assignment of a team area label label Jun 27, 2024
shane-zfx added a commit to shane-zfx/elasticsearch that referenced this issue Jun 27, 2024
- when the target character is detected, the loop ends
shane-zfx added a commit to shane-zfx/elasticsearch that referenced this issue Jun 27, 2024
- when the target character is detected, the loop ends
@astefan astefan added :Core/Infra/Core Core issues without another label and removed needs:triage Requires assignment of a team area label labels Jun 28, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team
Projects
None yet
Development

No branches or pull requests

3 participants