Make escape/unescape functions linear and not memory-storming.
Hello,
I am working on a project which does heavy use of JSON pointers (see #4859 ); while digging into the code I saw that the escape/unescape of JSON pointers was not linear, in example escaping "~~~~~~~~~~" requires 10 reallocations and 200 byte copies, escaping ; "~~~~~~~~~~~~~~~~~~~~" requires 20 reallocations and 800 byte copies.
I rewrote these two functions: one allocation and exactly two cycles on the key for escaping, no allocations and at most two loops for unescaping; I understand they are way less readable in this flavour but also way more efficient,
Existing tests already cover all the new code, I had to add iterators to the unit-alt-string "alt_string" class.
I tried to follow the CONTRIBUTING.md document throughly, but it's my first PR to this project, so forgive any mistake.
A.
coverage: 99.178% (-0.01%) from 99.191% when pulling f81406f9d9c8200fa229feb2f4915c989192cf8a on puffetto:develop into 3ed64e502a6371311af3c2f309e6525b2f5f6f18 on nlohmann:develop.
Clang-Tidy fails due to an update. I have not found the time to look into it - probably just some exclusions needed.
Clang-Tidy fails due to an update. I have not found the time to look into it - probably just some exclusions needed.
Oh, I see there are indeed some warnings related to the changed code. Please take a look to fix these.
Clang-Tidy fails due to an update. I have not found the time to look into it - probably just some exclusions needed.
Oh, I see there are indeed some warnings related to the changed code. Please take a look to fix these.
0d06a06629aa72788f7bcf96b2b2dbc4b41cbdd3 Should fix it
π΄ CI is red due to unrelated issues, see https://github.com/nlohmann/json/issues/4869.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
Please rebase to the latest develop branch as I just merged #4871.
This pull request has been marked as stale because it has had no activity for 30 days. While we wonβt close it automatically, we encourage you to update or comment if it is still relevant. Keeping pull requests active and up-to-date helps us review and merge changes more efficiently. Thank you for your contributions!
Hi @puffetto, can you please rebase?
Hi @puffetto, can you please rebase?
Done, sorry for taking so long, having personal problems these weeks/months.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
π΄ Amalgamation check failed! π΄
The source code has not been amalgamated. @puffetto Please read and follow the Contribution Guidelines.
Sorry I made some noise, I was working on the wrong branch and commits we unintentionally propagated here; I did reset now.
This pull request has been marked as stale because it has had no activity for 30 days. While we wonβt close it automatically, we encourage you to update or comment if it is still relevant. Keeping pull requests active and up-to-date helps us review and merge changes more efficiently. Thank you for your contributions!