Skip to content

Commit 6a90bff

Browse files
committed
gitk: Get rid of the childlist variable
The information in childlist is a duplicate of what's in the children array, and it wasn't being accessed often enough to be really worth keeping the list around as well. Signed-off-by: Paul Mackerras <[email protected]>
1 parent 62d3ea6 commit 6a90bff

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

gitk

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ proc getcommitlines {fd view} {
139139
global commitlisted
140140
global leftover commfd
141141
global displayorder commitidx commitrow commitdata
142-
global parentlist childlist children curview hlview
143-
global vparentlist vchildlist vdisporder vcmitlisted
142+
global parentlist children curview hlview
143+
global vparentlist vdisporder vcmitlisted
144144

145145
set stuff [read $fd 500000]
146146
if {$stuff == {}} {
@@ -237,12 +237,10 @@ proc getcommitlines {fd view} {
237237
incr commitidx($view)
238238
if {$view == $curview} {
239239
lappend parentlist $olds
240-
lappend childlist $children($view,$id)
241240
lappend displayorder $id
242241
lappend commitlisted $listed
243242
} else {
244243
lappend vparentlist($view) $olds
245-
lappend vchildlist($view) $children($view,$id)
246244
lappend vdisporder($view) $id
247245
lappend vcmitlisted($view) $listed
248246
}
@@ -1754,7 +1752,7 @@ proc unflatten {var l} {
17541752

17551753
proc showview {n} {
17561754
global curview viewdata viewfiles
1757-
global displayorder parentlist childlist rowidlist rowoffsets
1755+
global displayorder parentlist rowidlist rowoffsets
17581756
global colormap rowtextx commitrow nextcolor canvxmax
17591757
global numcommits rowrangelist commitlisted idrowranges rowchk
17601758
global selectedline currentid canv canvy0
@@ -1763,7 +1761,7 @@ proc showview {n} {
17631761
global commitidx rowlaidout rowoptim
17641762
global commfd
17651763
global selectedview selectfirst
1766-
global vparentlist vchildlist vdisporder vcmitlisted
1764+
global vparentlist vdisporder vcmitlisted
17671765
global hlview selectedhlview
17681766

17691767
if {$n == $curview} return
@@ -1789,7 +1787,6 @@ proc showview {n} {
17891787
stopfindproc
17901788
if {$curview >= 0} {
17911789
set vparentlist($curview) $parentlist
1792-
set vchildlist($curview) $childlist
17931790
set vdisporder($curview) $displayorder
17941791
set vcmitlisted($curview) $commitlisted
17951792
if {$phase ne {}} {
@@ -1828,7 +1825,6 @@ proc showview {n} {
18281825
set phase [lindex $v 0]
18291826
set displayorder $vdisporder($n)
18301827
set parentlist $vparentlist($n)
1831-
set childlist $vchildlist($n)
18321828
set commitlisted $vcmitlisted($n)
18331829
set rowidlist [lindex $v 1]
18341830
set rowoffsets [lindex $v 2]
@@ -1961,7 +1957,6 @@ proc addvhighlight {n} {
19611957
if {$n != $curview && ![info exists viewdata($n)]} {
19621958
set viewdata($n) [list getcommits {{}} {{}} {} {} {} 0 0 0 {}]
19631959
set vparentlist($n) {}
1964-
set vchildlist($n) {}
19651960
set vdisporder($n) {}
19661961
set vcmitlisted($n) {}
19671962
start_rev_list $n
@@ -2430,17 +2425,15 @@ proc ntimes {n o} {
24302425
}
24312426

24322427
proc usedinrange {id l1 l2} {
2433-
global children commitrow childlist curview
2428+
global children commitrow curview
24342429

24352430
if {[info exists commitrow($curview,$id)]} {
24362431
set r $commitrow($curview,$id)
24372432
if {$l1 <= $r && $r <= $l2} {
24382433
return [expr {$r - $l1 + 1}]
24392434
}
2440-
set kids [lindex $childlist $r]
2441-
} else {
2442-
set kids $children($curview,$id)
24432435
}
2436+
set kids $children($curview,$id)
24442437
foreach c $kids {
24452438
set r $commitrow($curview,$c)
24462439
if {$l1 <= $r && $r <= $l2} {
@@ -2515,15 +2508,14 @@ proc initlayout {} {
25152508
global idinlist rowchk rowrangelist idrowranges
25162509
global numcommits canvxmax canv
25172510
global nextcolor
2518-
global parentlist childlist children
2511+
global parentlist
25192512
global colormap rowtextx
25202513
global selectfirst
25212514

25222515
set numcommits 0
25232516
set displayorder {}
25242517
set commitlisted {}
25252518
set parentlist {}
2526-
set childlist {}
25272519
set rowrangelist {}
25282520
set nextcolor 0
25292521
set rowidlist {{}}
@@ -2721,7 +2713,7 @@ proc readdiffindex {fd serial} {
27212713
proc layoutrows {row endrow last} {
27222714
global rowidlist rowoffsets displayorder
27232715
global uparrowlen downarrowlen maxwidth mingaplen
2724-
global childlist parentlist
2716+
global children parentlist
27252717
global idrowranges
27262718
global commitidx curview
27272719
global idinlist rowchk rowrangelist
@@ -2771,7 +2763,7 @@ proc layoutrows {row endrow last} {
27712763
lappend idlist $id
27722764
lset rowidlist $row $idlist
27732765
set z {}
2774-
if {[lindex $childlist $row] ne {}} {
2766+
if {$children($curview,$id) ne {}} {
27752767
set z [expr {[llength [lindex $rowidlist [expr {$row-1}]]] - $col}]
27762768
unset idinlist($id)
27772769
}
@@ -2830,7 +2822,7 @@ proc layoutrows {row endrow last} {
28302822
proc addextraid {id row} {
28312823
global displayorder commitrow commitinfo
28322824
global commitidx commitlisted
2833-
global parentlist childlist children curview
2825+
global parentlist children curview
28342826

28352827
incr commitidx($curview)
28362828
lappend displayorder $id
@@ -2844,7 +2836,6 @@ proc addextraid {id row} {
28442836
if {![info exists children($curview,$id)]} {
28452837
set children($curview,$id) {}
28462838
}
2847-
lappend childlist $children($curview,$id)
28482839
}
28492840

28502841
proc layouttail {} {
@@ -3729,7 +3720,7 @@ proc show_status {msg} {
37293720
# The new commit will be displayed on row $row and the commits
37303721
# on that row and below will move down one row.
37313722
proc insertrow {row newcmit} {
3732-
global displayorder parentlist childlist commitlisted children
3723+
global displayorder parentlist commitlisted children
37333724
global commitrow curview rowidlist rowoffsets numcommits
37343725
global rowrangelist rowlaidout rowoptim numcommits
37353726
global selectedline rowchk commitidx
@@ -3741,11 +3732,10 @@ proc insertrow {row newcmit} {
37413732
set p [lindex $displayorder $row]
37423733
set displayorder [linsert $displayorder $row $newcmit]
37433734
set parentlist [linsert $parentlist $row $p]
3744-
set kids [lindex $childlist $row]
3735+
set kids $children($curview,$p)
37453736
lappend kids $newcmit
3746-
lset childlist $row $kids
3747-
set childlist [linsert $childlist $row {}]
37483737
set children($curview,$p) $kids
3738+
set children($curview,$newcmit) {}
37493739
set commitlisted [linsert $commitlisted $row 1]
37503740
set l [llength $displayorder]
37513741
for {set r $row} {$r < $l} {incr r} {
@@ -3802,7 +3792,7 @@ proc insertrow {row newcmit} {
38023792

38033793
# Remove a commit that was inserted with insertrow on row $row.
38043794
proc removerow {row} {
3805-
global displayorder parentlist childlist commitlisted children
3795+
global displayorder parentlist commitlisted children
38063796
global commitrow curview rowidlist rowoffsets numcommits
38073797
global rowrangelist idrowranges rowlaidout rowoptim numcommits
38083798
global linesegends selectedline rowchk commitidx
@@ -3816,13 +3806,11 @@ proc removerow {row} {
38163806
set p [lindex $parentlist $row]
38173807
set displayorder [lreplace $displayorder $row $row]
38183808
set parentlist [lreplace $parentlist $row $row]
3819-
set childlist [lreplace $childlist $row $row]
38203809
set commitlisted [lreplace $commitlisted $row $row]
3821-
set kids [lindex $childlist $row]
3810+
set kids $children($curview,$p)
38223811
set i [lsearch -exact $kids $id]
38233812
if {$i >= 0} {
38243813
set kids [lreplace $kids $i $i]
3825-
lset childlist $row $kids
38263814
set children($curview,$p) $kids
38273815
}
38283816
set l [llength $displayorder]
@@ -4264,7 +4252,7 @@ proc dispnexttag {} {
42644252
proc selectline {l isnew} {
42654253
global canv canv2 canv3 ctext commitinfo selectedline
42664254
global displayorder linehtag linentag linedtag
4267-
global canvy0 linespc parentlist childlist
4255+
global canvy0 linespc parentlist children curview
42684256
global currentid sha1entry
42694257
global commentend idtags linknum
42704258
global mergemax numcommits pending_select
@@ -4375,7 +4363,7 @@ proc selectline {l isnew} {
43754363
}
43764364
}
43774365

4378-
foreach c [lindex $childlist $l] {
4366+
foreach c $children($curview,$id) {
43794367
append headers "Child: [commit_descriptor $c]"
43804368
}
43814369

0 commit comments

Comments
 (0)