diff options
author | Paul Mackerras <paulus@samba.org> | 2006-10-14 19:21:02 +1000 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-06-23 20:55:52 +1000 |
commit | 66e46f37de3ed3211a8ae0e8fc09c063bc3a1e08 (patch) | |
tree | 99c9d46ed3bfe5a98deb8eabcf023eaeb3d9318b /gitk | |
parent | 00609463979c3a2549c0c917a206345f51975b5d (diff) | |
download | git-66e46f37de3ed3211a8ae0e8fc09c063bc3a1e08.tar.gz git-66e46f37de3ed3211a8ae0e8fc09c063bc3a1e08.tar.xz |
gitk: Store ids in rowrangelist and idrowranges rather than row numbers
This removes the need for insertrow to go through rowrangelist and
idrowranges and adjust a lot of entries. The first entry for a given
id is now the row number of the first child, not that row number + 1,
and rowranges compensates for that so its callers didn't have to
change. This adds a ranges argument to drawlineseg so that we can
avoid calling rowranges a second time inside drawlineseg (all its
callers already called rowranges).
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'gitk')
-rwxr-xr-x | gitk | 76 |
1 files changed, 28 insertions, 48 deletions
@@ -2472,7 +2472,7 @@ proc sanity {row {full 0}} { } proc makeuparrow {oid x y z} { - global rowidlist rowoffsets uparrowlen idrowranges + global rowidlist rowoffsets uparrowlen idrowranges displayorder for {set i 1} {$i < $uparrowlen && $y > 1} {incr i} { incr y -1 @@ -2495,7 +2495,7 @@ proc makeuparrow {oid x y z} { } set tmp [lreplace [lindex $rowoffsets $y] $x $x {}] lset rowoffsets $y [incrange $tmp [expr {$x+1}] -1] - lappend idrowranges($oid) $y + lappend idrowranges($oid) [lindex $displayorder $y] } proc initlayout {} { @@ -2609,7 +2609,7 @@ proc layoutmore {tmax allread} { proc showstuff {canshow} { global numcommits commitrow pending_select selectedline - global linesegends idrowranges idrangedrawn curview + global linesegends idrangedrawn curview global displayorder selectfirst if {$numcommits == 0} { @@ -2627,11 +2627,12 @@ proc showstuff {canshow} { for {set r $row} {$r < $canshow} {incr r} { foreach id [lindex $linesegends [expr {$r+1}]] { set i -1 - foreach {s e} [rowranges $id] { + set ranges [rowranges $id] + foreach {s e} $ranges { incr i if {$e ne {} && $e < $numcommits && $s <= $r1 && $e >= $r0 && ![info exists idrangedrawn($id,$i)]} { - drawlineseg $id $i + drawlineseg $id $i $ranges set idrangedrawn($id,$i) 1 } } @@ -2698,7 +2699,7 @@ proc layoutrows {row endrow last} { set idinlist($i) 0 set rm1 [expr {$row - 1}] lappend lse $i - lappend idrowranges($i) $rm1 + lappend idrowranges($i) [lindex $displayorder $rm1] if {[incr nev -1] <= 0} break continue } @@ -2730,7 +2731,7 @@ proc layoutrows {row endrow last} { set ranges {} if {[info exists idrowranges($id)]} { set ranges $idrowranges($id) - lappend ranges $row + lappend ranges $id unset idrowranges($id) } lappend rowrangelist $ranges @@ -2755,7 +2756,7 @@ proc layoutrows {row endrow last} { } foreach i $newolds { set idinlist($i) 1 - set idrowranges($i) $row + set idrowranges($i) $id } incr col $l foreach oid $oldolds { @@ -2993,16 +2994,22 @@ proc rowranges {id} { } elseif {[info exists idrowranges($id)]} { set ranges $idrowranges($id) } - return $ranges + set linenos {} + foreach rid $ranges { + lappend linenos $commitrow($curview,$rid) + } + if {$linenos ne {}} { + lset linenos 0 [expr {[lindex $linenos 0] + 1}] + } + return $linenos } -proc drawlineseg {id i} { +proc drawlineseg {id i ranges} { global rowoffsets rowidlist global displayorder global canv colormap linespc global numcommits commitrow curview - set ranges [rowranges $id] set downarrow 1 if {[info exists commitrow($curview,$id)] && $commitrow($curview,$id) < $numcommits} { @@ -3132,10 +3139,11 @@ proc drawlines {id} { global children iddrawn commitrow rowidlist curview $canv delete lines.$id - set nr [expr {[llength [rowranges $id]] / 2}] + set ranges [rowranges $id] + set nr [expr {[llength $ranges] / 2}] for {set i 0} {$i < $nr} {incr i} { if {[info exists idrangedrawn($id,$i)]} { - drawlineseg $id $i + drawlineseg $id $i $ranges } } foreach child $children($curview,$id) { @@ -3216,13 +3224,14 @@ proc drawcmitrow {row} { foreach id [lindex $rowidlist $row] { if {$id eq {}} continue set i -1 - foreach {s e} [rowranges $id] { + set ranges [rowranges $id] + foreach {s e} $ranges { incr i if {$row < $s} continue if {$e eq {}} break if {$row <= $e} { if {$e < $numcommits && ![info exists idrangedrawn($id,$i)]} { - drawlineseg $id $i + drawlineseg $id $i $ranges set idrangedrawn($id,$i) 1 } break @@ -3528,7 +3537,7 @@ proc show_status {msg} { proc insertrow {row newcmit} { global displayorder parentlist childlist commitlisted global commitrow curview rowidlist rowoffsets numcommits - global rowrangelist idrowranges rowlaidout rowoptim numcommits + global rowrangelist rowlaidout rowoptim numcommits global linesegends selectedline if {$row >= $numcommits} { @@ -3572,45 +3581,16 @@ proc insertrow {row newcmit} { set rowoffsets [linsert $rowoffsets [expr {$row+1}] $newoffs] set rowrangelist [linsert $rowrangelist $row {}] - set l [llength $rowrangelist] - for {set r 0} {$r < $l} {incr r} { - set ranges [lindex $rowrangelist $r] - if {$ranges ne {} && [lindex $ranges end] >= $row} { - set newranges {} - foreach x $ranges { - if {$x >= $row} { - lappend newranges [expr {$x + 1}] - } else { - lappend newranges $x - } - } - lset rowrangelist $r $newranges - } - } if {[llength $kids] > 1} { set rp1 [expr {$row + 1}] set ranges [lindex $rowrangelist $rp1] if {$ranges eq {}} { - set ranges [list $row $rp1] - } elseif {[lindex $ranges end-1] == $rp1} { - lset ranges end-1 $row + set ranges [list $newcmit $p] + } elseif {[lindex $ranges end-1] eq $p} { + lset ranges end-1 $newcmit } lset rowrangelist $rp1 $ranges } - foreach id [array names idrowranges] { - set ranges $idrowranges($id) - if {$ranges ne {} && [lindex $ranges end] >= $row} { - set newranges {} - foreach x $ranges { - if {$x >= $row} { - lappend newranges [expr {$x + 1}] - } else { - lappend newranges $x - } - } - set idrowranges($id) $newranges - } - } set linesegends [linsert $linesegends $row {}] |