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

optimize ListTreeNode Children for large JSON #187

Merged
merged 4 commits into from
Feb 27, 2019

Conversation

ousttrue
Copy link
Contributor

@ousttrue ousttrue commented Feb 8, 2019

No description provided.

@ousttrue ousttrue added this to the v0.51 milestone Feb 8, 2019
@ousttrue ousttrue changed the title optimize ListTreeNode Children for large JSON WIP optimize ListTreeNode Children for large JSON Feb 9, 2019
@ousttrue ousttrue force-pushed the optimize_ListTreeNode_Children branch from e0d36ed to 1ca7c20 Compare February 9, 2019 19:57
@ousttrue ousttrue changed the title WIP optimize ListTreeNode Children for large JSON optimize ListTreeNode Children for large JSON Feb 12, 2019
@ousttrue ousttrue modified the milestones: v0.51.0, v0.52.0 Feb 13, 2019
@yutopp
Copy link
Contributor

yutopp commented Feb 14, 2019

How can I check that the logic fixed by this PR is optimized?

@ousttrue
Copy link
Contributor Author

ousttrue commented Feb 14, 2019

Collection(Array/Object) that has many member's member access is slow.
Nested ...

var f = new JsonFormatter();
f.BeginObject();
f.Key("values");
f.BeginArray();
for(int i=0; i<10000; ++i)
{
    f.Value(i);
}
f.EndArray();
f.EndObject();
var parsed = f.GetStoreBytes().ParseAsJSon();

parsed["values"].ArrrayItem().Count() // <- this is slow
}

because

                int count = 0;

                //
                // before: All value enumerated
                // for (int i = ValueIndex; i < m_Values.Count; ++i) 
                //
                for (int i = ValueIndex; count < ChildCount && i < m_Values.Count; ++i)
                {	                {
                    if (m_Values[i].ParentIndex == ValueIndex)	                    if (m_Values[i].ParentIndex == ValueIndex)
                    {	                    {
                        ++count;
                        yield return new ListTreeNode<T>(m_Values, i);	                        yield return new ListTreeNode<T>(m_Values, i);
                    }	                    }
                }	                }

1ca7c20#diff-d7dfb11fb75a11ebf30df6d885eedab3R346

@ousttrue ousttrue merged commit 04b1aca into master Feb 27, 2019
@yutopp yutopp deleted the optimize_ListTreeNode_Children branch March 6, 2019 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants