Skip to content

Commit

Permalink
Free up a slot in the Node class by removing the "last" property. Thi…
Browse files Browse the repository at this point in the history
…s is done by making the "previous" node list circular, so that "first.previous" returns the same value as "last".

Here the "next" list is left as a simple list terminating with a null.  Originally, I attempted to use also make this circular (as the symmetry with the previous list was appealing).  However, this change "getNext" from a simple property retrieval to a conditional and this function is hot enough that it caused a compile time performance regression.  In this version "getNext" remains unchanged and no performance impact was measurable.

This has the following coding implications:
- in the Node class "previous" and "getPrevious()" no longer produce the same value
- it is no longer possible to call "getPrevious" on a detached Node as the "first" child of the parent must be known.
- removeChildren() returns a circular list
- "Children" and "Child" methods can no longer be used interchangeably for a single detached Node
- it is no longer possible to add a "tail" portion of a detached list

This change has the following benefits:
- the correct Child/Children methods must be called for the node structure

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129346032
  • Loading branch information
concavelenz authored and Dimitris Vardoulakis committed Aug 5, 2016
1 parent 9d5f544 commit 36ef45a
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 124 deletions.

0 comments on commit 36ef45a

Please sign in to comment.