Skip to content

Commit

Permalink
Speed up building the dictionary of reused Elm value encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
Viir committed Oct 5, 2024
1 parent 97f67f8 commit c95afbe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions implement/Pine.Core/ReusedInstances.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,15 @@ [.. elmRecord.Fields.Select(kvp => (kvp.FieldName, reusedInstances[kvp.Value]))]
{
var encodedDict = new Dictionary<ElmValue, PineValue>();

foreach (var item in ElmValues)
var elmValuesSorted =
ElmValues
.OrderBy(ev => ev.ContainedNodesCount)
.ToList();

foreach (var item in elmValuesSorted)
{
encodedDict[item] = ElmInteractive.ElmValueEncoding.ElmValueAsPineValue(item);
encodedDict[item] =
ElmInteractive.ElmValueEncoding.ElmValueAsPineValue(item, encodedDict);
}

ElmValueEncoding =
Expand Down

0 comments on commit c95afbe

Please sign in to comment.