elastic / elasticsearch

Free and Open, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
68.56k stars 24.35k forks source link

Optimize the loop processing of URL decoding #110235

Open shane-zfx opened 1 week ago

shane-zfx commented 1 week ago

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

https://github.com/elastic/elasticsearch/blob/4a49c08f3417cae17ababbc4134bf8e49be66e98/server/src/main/java/org/elasticsearch/rest/RestUtils.java#L148-L160

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 commented 1 week ago

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

rjernst commented 2 days ago

@shane-zfx Please feel free to open a PR.

shane-zfx commented 1 day ago

Yes, I have submitted the corresponding PR #110237 , please help me review it. :)