Skip to content
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

Performance: merge json array with existing list #6

Open
SamHurne opened this issue Sep 19, 2015 · 0 comments
Open

Performance: merge json array with existing list #6

SamHurne opened this issue Sep 19, 2015 · 0 comments
Milestone

Comments

@SamHurne
Copy link
Collaborator

[Moved from Codeplex: https://gw2dotnet.codeplex.com/workitem/1345]

Inspired by: https://forum-en.guildwars2.com/forum/community/api/Minor-issue-with-X-Result-Total/first#post5103839

The API returns the X-Result-Count of objects with every bulk-expanded response. We should use that value to specify the initial capacity of collection types.

collection.Capacity == X-Result-Count

Unfortunately, Json.NET does not support specifying a capacity for deserialized lists.

Fortunately, Json.NET supports merging json values with an existing object.

TODO (up for grabs)
update json collection converters to first create a new list with a specified capacity, then let Json.NET populate the list with objects

// Pseudo code
var list = new List<TDataContract>(X-Result-Count);
JsonConvert.PopulateObject(list, httpResponseContent);
@Ruhrpottpatriot Ruhrpottpatriot added this to the v2.0.0 milestone Oct 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants