Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sync code #1
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
Uh oh!
There was an error while loading. Please reload this page.
Sync code #1
Changes from 1 commit
a54b9c80392c1aac1cf4ca1f162407e86f1b635cf25159573ba52f9df0c7534d2834751be2db9e6d7ae77ec1110d45cac60427ef993cd68fae2d17bc6fcf2eda5bd2b8e7603943f236dd1d6a6bca8d6f03741887d6c28d43db080ce500dada707e94954e0b8cf978fd273db668a5283f95fe99c5c391f6c98c9dcbc5f53c377fa6cc3b1ed0dd8e9aa7e6bd94afda14226346c0f4fa655b1f368fdc1f86a3bf40a329c4e3b612deb226d9e9fecca73d014fe35c0c7d3e1cf79263138a808757581876f7639158141c01efb89765a3c95b9a8d62d2c918ce42797d9b92d8ff1893e81671f38fd485f4012630cc9f2156251ece3d37a81c6d9096460ccb8358704571df3e04d38d81930da21ffd8e317c118b8fa506486fa786e89dabad1972fe01104d6eaa8ea1b88d3b9cc07299a2818c5588193f420717e8dad1375b217b1849c0fd3025e30c58debe3bc150890d59648ba039c2508c70215145eeae953bb9622e1f47c96347390d8c92caa4ca236893aa1c334434b320c81f49a590cb4e97bd6d14b22241780220b3b91602552b1c087ca4642a67769aebb6682fee265c80556087ee5db93d9b43b0cd577abea9e6b25c3bd3569b988f2547f41715c781e002f9f322a3287f9f5d3cfb1640e9d9a22dee15f5d860bdceab93452a999ac07e8b9e014515ffcff01cab296dadf7cd2e24fae5997217ffff3fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
* Improve throughput / allocations of JsonNode.GetPath The current implementation is creating a `List<string>` and appending each segment to it, which in most of the cases is allocating a `string`. Then it iterates through that list in reverse order appending to a newly-created `StringBuilder`, which it then `ToString`s. In this change, it instead just uses `ValueStringBuilder`, appending to it as it goes. In doing so, it does reverse the order of enumeration. Previously each node would effectively do: ```C# void GetPath() { AddNode(this); parent?.GetPath(); } ``` and now it's doing: ```C# void GetPath() { parent?.GetPath(); AddNode(this); } ``` While C# doesn't emit tail calls, with optimizations enabled, it's feasible the JIT might emit the recursive call as a jmp rather than a call, in which case it would avoid possible stack dives. However, that's not guaranteed, and doesn't happen today in tier 0 and other unoptimized code. On top of that, to get such a deep nesting in a JsonNode, you need to either go out of your way to create one manually using the JsonNode/Object/Array/Value constructors, or you need to use JsonSerializer.Deserializer, overriding its default MaxDepth, and in the case of a really deep input, it's also recursive and will stack overflow in smaller situations. I have a different version of this change that keeps the same ordering, passing around a span and a length separately, and prepending to the end of the span, but it results in more complicated code, so I'd prefer this variation that just uses ValueStringBuilder unless we have real concerns. * Address PR feedbackUh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing