Skip to content

Commit

Permalink
gitk: Get rid of the childlist variable
Browse files Browse the repository at this point in the history
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 <paulus@samba.org>
  • Loading branch information
Paul Mackerras committed Jun 23, 2007
1 parent 62d3ea6 commit 6a90bff
Showing 1 changed file with 17 additions and 29 deletions.
46 changes: 17 additions & 29 deletions gitk
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ proc getcommitlines {fd view} {
global commitlisted
global leftover commfd
global displayorder commitidx commitrow commitdata
global parentlist childlist children curview hlview
global vparentlist vchildlist vdisporder vcmitlisted
global parentlist children curview hlview
global vparentlist vdisporder vcmitlisted

set stuff [read $fd 500000]
if {$stuff == {}} {
Expand Down Expand Up @@ -237,12 +237,10 @@ proc getcommitlines {fd view} {
incr commitidx($view)
if {$view == $curview} {
lappend parentlist $olds
lappend childlist $children($view,$id)
lappend displayorder $id
lappend commitlisted $listed
} else {
lappend vparentlist($view) $olds
lappend vchildlist($view) $children($view,$id)
lappend vdisporder($view) $id
lappend vcmitlisted($view) $listed
}
Expand Down Expand Up @@ -1754,7 +1752,7 @@ proc unflatten {var l} {

proc showview {n} {
global curview viewdata viewfiles
global displayorder parentlist childlist rowidlist rowoffsets
global displayorder parentlist rowidlist rowoffsets
global colormap rowtextx commitrow nextcolor canvxmax
global numcommits rowrangelist commitlisted idrowranges rowchk
global selectedline currentid canv canvy0
Expand All @@ -1763,7 +1761,7 @@ proc showview {n} {
global commitidx rowlaidout rowoptim
global commfd
global selectedview selectfirst
global vparentlist vchildlist vdisporder vcmitlisted
global vparentlist vdisporder vcmitlisted
global hlview selectedhlview

if {$n == $curview} return
Expand All @@ -1789,7 +1787,6 @@ proc showview {n} {
stopfindproc
if {$curview >= 0} {
set vparentlist($curview) $parentlist
set vchildlist($curview) $childlist
set vdisporder($curview) $displayorder
set vcmitlisted($curview) $commitlisted
if {$phase ne {}} {
Expand Down Expand Up @@ -1828,7 +1825,6 @@ proc showview {n} {
set phase [lindex $v 0]
set displayorder $vdisporder($n)
set parentlist $vparentlist($n)
set childlist $vchildlist($n)
set commitlisted $vcmitlisted($n)
set rowidlist [lindex $v 1]
set rowoffsets [lindex $v 2]
Expand Down Expand Up @@ -1961,7 +1957,6 @@ proc addvhighlight {n} {
if {$n != $curview && ![info exists viewdata($n)]} {
set viewdata($n) [list getcommits {{}} {{}} {} {} {} 0 0 0 {}]
set vparentlist($n) {}
set vchildlist($n) {}
set vdisporder($n) {}
set vcmitlisted($n) {}
start_rev_list $n
Expand Down Expand Up @@ -2430,17 +2425,15 @@ proc ntimes {n o} {
}

proc usedinrange {id l1 l2} {
global children commitrow childlist curview
global children commitrow curview

if {[info exists commitrow($curview,$id)]} {
set r $commitrow($curview,$id)
if {$l1 <= $r && $r <= $l2} {
return [expr {$r - $l1 + 1}]
}
set kids [lindex $childlist $r]
} else {
set kids $children($curview,$id)
}
set kids $children($curview,$id)
foreach c $kids {
set r $commitrow($curview,$c)
if {$l1 <= $r && $r <= $l2} {
Expand Down Expand Up @@ -2515,15 +2508,14 @@ proc initlayout {} {
global idinlist rowchk rowrangelist idrowranges
global numcommits canvxmax canv
global nextcolor
global parentlist childlist children
global parentlist
global colormap rowtextx
global selectfirst

set numcommits 0
set displayorder {}
set commitlisted {}
set parentlist {}
set childlist {}
set rowrangelist {}
set nextcolor 0
set rowidlist {{}}
Expand Down Expand Up @@ -2721,7 +2713,7 @@ proc readdiffindex {fd serial} {
proc layoutrows {row endrow last} {
global rowidlist rowoffsets displayorder
global uparrowlen downarrowlen maxwidth mingaplen
global childlist parentlist
global children parentlist
global idrowranges
global commitidx curview
global idinlist rowchk rowrangelist
Expand Down Expand Up @@ -2771,7 +2763,7 @@ proc layoutrows {row endrow last} {
lappend idlist $id
lset rowidlist $row $idlist
set z {}
if {[lindex $childlist $row] ne {}} {
if {$children($curview,$id) ne {}} {
set z [expr {[llength [lindex $rowidlist [expr {$row-1}]]] - $col}]
unset idinlist($id)
}
Expand Down Expand Up @@ -2830,7 +2822,7 @@ proc layoutrows {row endrow last} {
proc addextraid {id row} {
global displayorder commitrow commitinfo
global commitidx commitlisted
global parentlist childlist children curview
global parentlist children curview

incr commitidx($curview)
lappend displayorder $id
Expand All @@ -2844,7 +2836,6 @@ proc addextraid {id row} {
if {![info exists children($curview,$id)]} {
set children($curview,$id) {}
}
lappend childlist $children($curview,$id)
}

proc layouttail {} {
Expand Down Expand Up @@ -3729,7 +3720,7 @@ proc show_status {msg} {
# The new commit will be displayed on row $row and the commits
# on that row and below will move down one row.
proc insertrow {row newcmit} {
global displayorder parentlist childlist commitlisted children
global displayorder parentlist commitlisted children
global commitrow curview rowidlist rowoffsets numcommits
global rowrangelist rowlaidout rowoptim numcommits
global selectedline rowchk commitidx
Expand All @@ -3741,11 +3732,10 @@ proc insertrow {row newcmit} {
set p [lindex $displayorder $row]
set displayorder [linsert $displayorder $row $newcmit]
set parentlist [linsert $parentlist $row $p]
set kids [lindex $childlist $row]
set kids $children($curview,$p)
lappend kids $newcmit
lset childlist $row $kids
set childlist [linsert $childlist $row {}]
set children($curview,$p) $kids
set children($curview,$newcmit) {}
set commitlisted [linsert $commitlisted $row 1]
set l [llength $displayorder]
for {set r $row} {$r < $l} {incr r} {
Expand Down Expand Up @@ -3802,7 +3792,7 @@ proc insertrow {row newcmit} {

# Remove a commit that was inserted with insertrow on row $row.
proc removerow {row} {
global displayorder parentlist childlist commitlisted children
global displayorder parentlist commitlisted children
global commitrow curview rowidlist rowoffsets numcommits
global rowrangelist idrowranges rowlaidout rowoptim numcommits
global linesegends selectedline rowchk commitidx
Expand All @@ -3816,13 +3806,11 @@ proc removerow {row} {
set p [lindex $parentlist $row]
set displayorder [lreplace $displayorder $row $row]
set parentlist [lreplace $parentlist $row $row]
set childlist [lreplace $childlist $row $row]
set commitlisted [lreplace $commitlisted $row $row]
set kids [lindex $childlist $row]
set kids $children($curview,$p)
set i [lsearch -exact $kids $id]
if {$i >= 0} {
set kids [lreplace $kids $i $i]
lset childlist $row $kids
set children($curview,$p) $kids
}
set l [llength $displayorder]
Expand Down Expand Up @@ -4264,7 +4252,7 @@ proc dispnexttag {} {
proc selectline {l isnew} {
global canv canv2 canv3 ctext commitinfo selectedline
global displayorder linehtag linentag linedtag
global canvy0 linespc parentlist childlist
global canvy0 linespc parentlist children curview
global currentid sha1entry
global commentend idtags linknum
global mergemax numcommits pending_select
Expand Down Expand Up @@ -4375,7 +4363,7 @@ proc selectline {l isnew} {
}
}

foreach c [lindex $childlist $l] {
foreach c $children($curview,$id) {
append headers "Child: [commit_descriptor $c]"
}

Expand Down

0 comments on commit 6a90bff

Please sign in to comment.