File tree Expand file tree Collapse file tree
src/main/java/org/glavo/nbt/tag Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,9 +115,7 @@ public void remove(Tag tag) {
115115 tag .parent = null ;
116116
117117 // Update the index of the successor tags.
118- for (int i = subtagIndex ; i < subTags .size (); i ++) {
119- subTags .get (i ).index = i ;
120- }
118+ updateIndexes (subtagIndex );
121119 }
122120
123121 @ Override
Original file line number Diff line number Diff line change @@ -149,9 +149,7 @@ public void remove(Tag tag) {
149149 tag .parent = null ;
150150
151151 // Update the index of the successor tags.
152- for (int i = subtagIndex ; i < subTags .size (); i ++) {
153- subTags .get (i ).index = i ;
154- }
152+ updateIndexes (subtagIndex );
155153 }
156154
157155 @ Override
Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ protected ParentTag(String name) {
3737 /// @see Tag#setName(String)
3838 abstract void updateSubTagName (Tag tag , String name ) throws IllegalStateException ;
3939
40+ protected final void updateIndexes (int startIndex ) {
41+ for (int i = startIndex , end = subTags .size (); i < end ; i ++) {
42+ subTags .get (i ).index = i ;
43+ }
44+ }
45+
4046 /// Returns `true` if this tag is the root tag, `false` otherwise.
4147 public final boolean isRoot () {
4248 return parent == null ;
You can’t perform that action at this time.
0 commit comments