contentful / contentful.net

.NET Library for Contentful's Content Delivery and Management API
MIT License
95 stars 55 forks source link

GetEntries<T> calls ToObject twice for the same json property #326

Closed orlando-popescu closed 10 months ago

orlando-popescu commented 10 months ago

I may be missing some context on why it is done this way, but the GetEntries<T> method in ContentfulClient.cs deserializes the $.items property twice, impacting performance.

The section of the code that I am referring to is: entries = json.SelectToken("$.items").ToObject<IEnumerable<T>>(Serializer); var collection = json.ToObject<ContentfulCollection<T>>(Serializer); collection.Items = entries;

The list of entries is first deserialized by specifying the $.items property, however, the whole JSON ( including all $items objects) is deserialized again on the next line.

Roblinde commented 10 months ago

@orlando-popescu this is true, I removed the superflous call and ran through all tests and it is just a complete oversight. Thank you for noticing, it'll improve performance slightly for the next release.