@matheusbsbs / matheus-bagliano / commits / 66e46f37de
Fork 0

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>

Paul Mackerras committed Oct 14, 2006 at 19:21 UTC 66e46f37de3ed3211a8ae0e8fc09c063bc3a1e08
1 file changed +28 -48
gitk
+28 -48
@@ -2472,7 +2472,7 @@ proc sanity {row {full 0}} {
2472 }
2473
2474 proc makeuparrow {oid x y z} {
2475 - global rowidlist rowoffsets uparrowlen idrowranges
2475 + global rowidlist rowoffsets uparrowlen idrowranges displayorder
2476
2477 for {set i 1} {$i < $uparrowlen && $y > 1} {incr i} {
2478 incr y -1
@@ -2495,7 +2495,7 @@ proc makeuparrow {oid x y z} {
2495 }
2496 set tmp [lreplace [lindex $rowoffsets $y] $x $x {}]
2497 lset rowoffsets $y [incrange $tmp [expr {$x+1}] -1]
2498 - lappend idrowranges($oid) $y
2498 + lappend idrowranges($oid) [lindex $displayorder $y]
2499 }
2500
2501 proc initlayout {} {
@@ -2609,7 +2609,7 @@ proc layoutmore {tmax allread} {
2609
2610 proc showstuff {canshow} {
2611 global numcommits commitrow pending_select selectedline
2612 - global linesegends idrowranges idrangedrawn curview
2612 + global linesegends idrangedrawn curview
2613 global displayorder selectfirst
2614
2615 if {$numcommits == 0} {
@@ -2627,11 +2627,12 @@ proc showstuff {canshow} {
2627 for {set r $row} {$r < $canshow} {incr r} {
2628 foreach id [lindex $linesegends [expr {$r+1}]] {
2629 set i -1
2630 - foreach {s e} [rowranges $id] {
2630 + set ranges [rowranges $id]
2631 + foreach {s e} $ranges {
2632 incr i
2633 if {$e ne {} && $e < $numcommits && $s <= $r1 && $e >= $r0
2634 && ![info exists idrangedrawn($id,$i)]} {
2634 - drawlineseg $id $i
2635 + drawlineseg $id $i $ranges
2636 set idrangedrawn($id,$i) 1
2637 }
2638 }
@@ -2698,7 +2699,7 @@ proc layoutrows {row endrow last} {
2699 set idinlist($i) 0
2700 set rm1 [expr {$row - 1}]
2701 lappend lse $i
2701 - lappend idrowranges($i) $rm1
2702 + lappend idrowranges($i) [lindex $displayorder $rm1]
2703 if {[incr nev -1] <= 0} break
2704 continue
2705 }
@@ -2730,7 +2731,7 @@ proc layoutrows {row endrow last} {
2731 set ranges {}
2732 if {[info exists idrowranges($id)]} {
2733 set ranges $idrowranges($id)
2733 - lappend ranges $row
2734 + lappend ranges $id
2735 unset idrowranges($id)
2736 }
2737 lappend rowrangelist $ranges
@@ -2755,7 +2756,7 @@ proc layoutrows {row endrow last} {
2756 }
2757 foreach i $newolds {
2758 set idinlist($i) 1
2758 - set idrowranges($i) $row
2759 + set idrowranges($i) $id
2760 }
2761 incr col $l
2762 foreach oid $oldolds {
@@ -2993,16 +2994,22 @@ proc rowranges {id} {
2994 } elseif {[info exists idrowranges($id)]} {
2995 set ranges $idrowranges($id)
2996 }
2996 - return $ranges
2997 + set linenos {}
2998 + foreach rid $ranges {
2999 + lappend linenos $commitrow($curview,$rid)
3000 + }
3001 + if {$linenos ne {}} {
3002 + lset linenos 0 [expr {[lindex $linenos 0] + 1}]
3003 + }
3004 + return $linenos
3005 }
3006
2999 -proc drawlineseg {id i} {
3007 +proc drawlineseg {id i ranges} {
3008 global rowoffsets rowidlist
3009 global displayorder
3010 global canv colormap linespc
3011 global numcommits commitrow curview
3012
3005 - set ranges [rowranges $id]
3013 set downarrow 1
3014 if {[info exists commitrow($curview,$id)]
3015 && $commitrow($curview,$id) < $numcommits} {
@@ -3132,10 +3139,11 @@ proc drawlines {id} {
3139 global children iddrawn commitrow rowidlist curview
3140
3141 $canv delete lines.$id
3135 - set nr [expr {[llength [rowranges $id]] / 2}]
3142 + set ranges [rowranges $id]
3143 + set nr [expr {[llength $ranges] / 2}]
3144 for {set i 0} {$i < $nr} {incr i} {
3145 if {[info exists idrangedrawn($id,$i)]} {
3138 - drawlineseg $id $i
3146 + drawlineseg $id $i $ranges
3147 }
3148 }
3149 foreach child $children($curview,$id) {
@@ -3216,13 +3224,14 @@ proc drawcmitrow {row} {
3224 foreach id [lindex $rowidlist $row] {
3225 if {$id eq {}} continue
3226 set i -1
3219 - foreach {s e} [rowranges $id] {
3227 + set ranges [rowranges $id]
3228 + foreach {s e} $ranges {
3229 incr i
3230 if {$row < $s} continue
3231 if {$e eq {}} break
3232 if {$row <= $e} {
3233 if {$e < $numcommits && ![info exists idrangedrawn($id,$i)]} {
3225 - drawlineseg $id $i
3234 + drawlineseg $id $i $ranges
3235 set idrangedrawn($id,$i) 1
3236 }
3237 break
@@ -3528,7 +3537,7 @@ proc show_status {msg} {
3537 proc insertrow {row newcmit} {
3538 global displayorder parentlist childlist commitlisted
3539 global commitrow curview rowidlist rowoffsets numcommits
3531 - global rowrangelist idrowranges rowlaidout rowoptim numcommits
3540 + global rowrangelist rowlaidout rowoptim numcommits
3541 global linesegends selectedline
3542
3543 if {$row >= $numcommits} {
@@ -3572,45 +3581,16 @@ proc insertrow {row newcmit} {
3581 set rowoffsets [linsert $rowoffsets [expr {$row+1}] $newoffs]
3582
3583 set rowrangelist [linsert $rowrangelist $row {}]
3575 - set l [llength $rowrangelist]
3576 - for {set r 0} {$r < $l} {incr r} {
3577 - set ranges [lindex $rowrangelist $r]
3578 - if {$ranges ne {} && [lindex $ranges end] >= $row} {
3579 - set newranges {}
3580 - foreach x $ranges {
3581 - if {$x >= $row} {
3582 - lappend newranges [expr {$x + 1}]
3583 - } else {
3584 - lappend newranges $x
3585 - }
3586 - }
3587 - lset rowrangelist $r $newranges
3588 - }
3589 - }
3584 if {[llength $kids] > 1} {
3585 set rp1 [expr {$row + 1}]
3586 set ranges [lindex $rowrangelist $rp1]
3587 if {$ranges eq {}} {
3594 - set ranges [list $row $rp1]
3595 - } elseif {[lindex $ranges end-1] == $rp1} {
3596 - lset ranges end-1 $row
3588 + set ranges [list $newcmit $p]
3589 + } elseif {[lindex $ranges end-1] eq $p} {
3590 + lset ranges end-1 $newcmit
3591 }
3592 lset rowrangelist $rp1 $ranges
3593 }
3600 - foreach id [array names idrowranges] {
3601 - set ranges $idrowranges($id)
3602 - if {$ranges ne {} && [lindex $ranges end] >= $row} {
3603 - set newranges {}
3604 - foreach x $ranges {
3605 - if {$x >= $row} {
3606 - lappend newranges [expr {$x + 1}]
3607 - } else {
3608 - lappend newranges $x
3609 - }
3610 - }
3611 - set idrowranges($id) $newranges
3612 - }
3613 - }
3594
3595 set linesegends [linsert $linesegends $row {}]
3596