Json: improve JsonElement property access caching in deduplication scenarios
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
test: Json_projection_deduplication_with_collection_indexer_in_original
query
```cs
ss.Set().Select(x => new
{
x.Id,
Duplicate1 = x.OwnedCollectionRoot[0].OwnedReferenceBranch,
Original = x.OwnedCollectionRoot[0],
Duplicate2 = x.OwnedCollectionRoot[0].OwnedReferenceBranch.OwnedCollectionLeaf
}).AsNoTracking()
```
in shaper we extract OwnedReferenceBranch twice:
```cs
namelessParameter{3} = namelessParameter{1}.HasValue ? (JsonElement?)namelessParameter{1}.Value.GetProperty("OwnedReferenceBranch") : default(JsonElement?);
namelessParameter{6} = namelessParameter{1}.HasValue ? (JsonElement?)namelessParameter{1}.Value.GetProperty("OwnedReferenceBranch") : default(JsonElement?);
namelessParameter{7} = namelessParameter{6}.HasValue ? (JsonElement?)namelessParameter{6}.Value.GetProperty("OwnedCollectionLeaf") : default(JsonElement?);
```
we could cache at every step and re-use instead. Would need to key off root JsonElement + additional path, which might be bit annoying.
Contributor guide
Assessment
This issue has not been assessed yet.