@matheusbsbs / matheus-bagliano / commits / 8f7d0cecf4
Fork 0

gitk: Various speed improvements

This rearranges the code a little to eliminate some procedure calls and reduce the number of globals accessed. It makes rowidlist and rowoffsets lists rather than arrays, and removes the lineid array, since $lineid($l) was the same as [lindex $displayorder $l], and the latter is a little faster. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Feb 28, 2006 at 22:10 UTC 8f7d0cecf4b4999f71e0c5346de2f24beebd67dd
1 file changed +112 -116
gitk
+112 -116
@@ -39,6 +39,7 @@ proc start_rev_list {rlargs} {
39 set startmsecs [clock clicks -milliseconds]
40 set nextupdate [expr {$startmsecs + 100}]
41 set ncmupdate 1
42 + initlayout
43 set order "--topo-order"
44 if {$datemode} {
45 set order "--date-order"
@@ -72,9 +73,10 @@ proc getcommits {rargs} {
73
74 proc getcommitlines {commfd} {
75 global parents cdate children nchildren
75 - global commitlisted nextupdate
76 + global commitlisted commitinfo phase nextupdate
77 global stopped leftover
78 global canv
79 + global displayorder commitidx commitrow
80
81 set stuff [read $commfd]
82 if {$stuff == {}} {
@@ -97,16 +99,19 @@ proc getcommitlines {commfd} {
99 exit 1
100 }
101 set start 0
102 + set gotsome 0
103 while 1 {
104 set i [string first "\0" $stuff $start]
105 if {$i < 0} {
106 append leftover [string range $stuff $start end]
107 break
108 }
106 - set cmit [string range $stuff $start [expr {$i - 1}]]
109 if {$start == 0} {
108 - set cmit "$leftover$cmit"
110 + set cmit $leftover
111 + append cmit [string range $stuff 0 [expr {$i - 1}]]
112 set leftover {}
113 + } else {
114 + set cmit [string range $stuff $start [expr {$i - 1}]]
115 }
116 set start [expr {$i + 1}]
117 set j [string first "\n" $cmit]
@@ -115,7 +120,7 @@ proc getcommitlines {commfd} {
120 set ids [string range $cmit 0 [expr {$j - 1}]]
121 set ok 1
122 foreach id $ids {
118 - if {![regexp {^[0-9a-f]{40}$} $id]} {
123 + if {[string length $id] != 40} {
124 set ok 0
125 break
126 }
@@ -133,10 +138,18 @@ proc getcommitlines {commfd} {
138 set olds [lrange $ids 1 end]
139 set cmit [string range $cmit [expr {$j + 1}] end]
140 set commitlisted($id) 1
136 - parsecommit $id $cmit 1 [lrange $ids 1 end]
137 - drawcommit $id 1
141 + updatechildren $id [lrange $ids 1 end]
142 + if {![info exists commitinfo($id)]} {
143 + parsecommit $id $cmit 1
144 + }
145 + set commitrow($id) $commitidx
146 + incr commitidx
147 + lappend displayorder $id
148 + set gotsome 1
149 + }
150 + if {$gotsome} {
151 + layoutmore
152 }
139 - layoutmore
153 if {[clock clicks -milliseconds] >= $nextupdate} {
154 doupdate 1
155 }
@@ -164,14 +177,15 @@ proc doupdate {reading} {
177
178 proc readcommit {id} {
179 if {[catch {set contents [exec git-cat-file commit $id]}]} return
167 - parsecommit $id $contents 0 {}
180 + updatechildren $id {}
181 + parsecommit $id $contents 0
182 }
183
184 proc updatecommits {rargs} {
185 stopfindproc
186 foreach v {children nchildren parents nparents commitlisted
173 - commitinfo colormap selectedline matchinglines treediffs
174 - mergefilelist currentid rowtextx commitrow lineid
187 + colormap selectedline matchinglines treediffs
188 + mergefilelist currentid rowtextx commitrow
189 rowidlist rowoffsets idrowranges idrangedrawn iddrawn
190 linesegends crossings cornercrossings} {
191 global $v
@@ -202,7 +216,7 @@ proc updatechildren {id olds} {
216 }
217 }
218
205 -proc parsecommit {id contents listed olds} {
219 +proc parsecommit {id contents listed} {
220 global commitinfo cdate
221
222 set inhdr 1
@@ -212,7 +226,6 @@ proc parsecommit {id contents listed olds} {
226 set audate {}
227 set comname {}
228 set comdate {}
215 - updatechildren $id $olds
229 set hdrend [string first "\n\n" $contents]
230 if {$hdrend < 0} {
231 # should never happen...
@@ -741,30 +754,30 @@ proc sanity {row {full 0}} {
754 global rowidlist rowoffsets
755
756 set col -1
744 - set ids $rowidlist($row)
757 + set ids [lindex $rowidlist $row]
758 foreach id $ids {
759 incr col
760 if {$id eq {}} continue
761 if {$col < [llength $ids] - 1 &&
762 [lsearch -exact -start [expr {$col+1}] $ids $id] >= 0} {
750 - puts "oops: [shortids $id] repeated in row $row col $col: {[shortids $rowidlist($row)]}"
763 + puts "oops: [shortids $id] repeated in row $row col $col: {[shortids [lindex $rowidlist $row]]}"
764 }
752 - set o [lindex $rowoffsets($row) $col]
765 + set o [lindex $rowoffsets $row $col]
766 set y $row
767 set x $col
768 while {$o ne {}} {
769 incr y -1
770 incr x $o
758 - if {[lindex $rowidlist($y) $x] != $id} {
771 + if {[lindex $rowidlist $y $x] != $id} {
772 puts "oops: rowoffsets wrong at row [expr {$y+1}] col [expr {$x-$o}]"
773 puts " id=[shortids $id] check started at row $row"
774 for {set i $row} {$i >= $y} {incr i -1} {
762 - puts " row $i ids={[shortids $rowidlist($i)]} offs={$rowoffsets($i)}"
775 + puts " row $i ids={[shortids [lindex $rowidlist $i]]} offs={[lindex $rowoffsets $i]}"
776 }
777 break
778 }
779 if {!$full} break
767 - set o [lindex $rowoffsets($y) $x]
780 + set o [lindex $rowoffsets $y $x]
781 }
782 }
783 }
@@ -775,10 +788,10 @@ proc makeuparrow {oid x y z} {
788 for {set i 1} {$i < $uparrowlen && $y > 1} {incr i} {
789 incr y -1
790 incr x $z
778 - set off0 $rowoffsets($y)
791 + set off0 [lindex $rowoffsets $y]
792 for {set x0 $x} {1} {incr x0} {
793 if {$x0 >= [llength $off0]} {
781 - set x0 [llength $rowoffsets([expr {$y-1}])]
794 + set x0 [llength [lindex $rowoffsets [expr {$y-1}]]]
795 break
796 }
797 set z [lindex $off0 $x0]
@@ -788,11 +801,11 @@ proc makeuparrow {oid x y z} {
801 }
802 }
803 set z [expr {$x0 - $x}]
791 - set rowidlist($y) [linsert $rowidlist($y) $x $oid]
792 - set rowoffsets($y) [linsert $rowoffsets($y) $x $z]
804 + lset rowidlist $y [linsert [lindex $rowidlist $y] $x $oid]
805 + lset rowoffsets $y [linsert [lindex $rowoffsets $y] $x $z]
806 }
794 - set tmp [lreplace $rowoffsets($y) $x $x {}]
795 - set rowoffsets($y) [incrange $tmp [expr {$x+1}] -1]
807 + set tmp [lreplace [lindex $rowoffsets $y] $x $x {}]
808 + lset rowoffsets $y [incrange $tmp [expr {$x+1}] -1]
809 lappend idrowranges($oid) $y
810 }
811
@@ -800,9 +813,15 @@ proc initlayout {} {
813 global rowidlist rowoffsets displayorder
814 global rowlaidout rowoptim
815 global idinlist rowchk
816 + global commitidx numcommits
817 + global nextcolor
818
804 - set rowidlist(0) {}
805 - set rowoffsets(0) {}
819 + set commitidx 0
820 + set numcommits 0
821 + set displayorder {}
822 + set nextcolor 0
823 + set rowidlist {{}}
824 + set rowoffsets {{}}
825 catch {unset idinlist}
826 catch {unset rowchk}
827 set rowlaidout 0
@@ -851,6 +870,11 @@ proc showstuff {canshow} {
870 global canvy0 linespc
871 global linesegends idrowranges idrangedrawn
872
873 + if {$numcommits == 0} {
874 + global phase
875 + set phase "incrdraw"
876 + allcanvs delete all
877 + }
878 set row $numcommits
879 set numcommits $canshow
880 allcanvs conf -scrollregion \
@@ -890,8 +914,8 @@ proc layoutrows {row endrow last} {
914 global commitidx
915 global idinlist rowchk
916
893 - set idlist $rowidlist($row)
894 - set offs $rowoffsets($row)
917 + set idlist [lindex $rowidlist $row]
918 + set offs [lindex $rowoffsets $row]
919 while {$row < $endrow} {
920 set id [lindex $displayorder $row]
921 set oldolds {}
@@ -925,21 +949,21 @@ proc layoutrows {row endrow last} {
949 set rowchk($id) [expr {$row + $r}]
950 }
951 }
928 - set rowidlist($row) $idlist
929 - set rowoffsets($row) $offs
952 + lset rowidlist $row $idlist
953 + lset rowoffsets $row $offs
954 }
955 set col [lsearch -exact $idlist $id]
956 if {$col < 0} {
957 set col [llength $idlist]
958 lappend idlist $id
935 - set rowidlist($row) $idlist
959 + lset rowidlist $row $idlist
960 set z {}
961 if {$nchildren($id) > 0} {
938 - set z [expr {[llength $rowidlist([expr {$row-1}])] - $col}]
962 + set z [expr {[llength [lindex $rowidlist [expr {$row-1}]]] - $col}]
963 unset idinlist($id)
964 }
965 lappend offs $z
942 - set rowoffsets($row) $offs
966 + lset rowoffsets $row $offs
967 if {$z ne {}} {
968 makeuparrow $id $col $row $z
969 }
@@ -981,20 +1005,19 @@ proc layoutrows {row endrow last} {
1005 makeuparrow $oid $col $row $o
1006 incr col
1007 }
984 - set rowidlist($row) $idlist
985 - set rowoffsets($row) $offs
1008 + lappend rowidlist $idlist
1009 + lappend rowoffsets $offs
1010 }
1011 return $row
1012 }
1013
1014 proc addextraid {id row} {
991 - global displayorder commitrow lineid commitinfo nparents
1015 + global displayorder commitrow commitinfo nparents
1016 global commitidx
1017
1018 incr commitidx
1019 lappend displayorder $id
1020 set commitrow($id) $row
997 - set lineid($row) $id
1021 readcommit $id
1022 if {![info exists commitinfo($id)]} {
1023 set commitinfo($id) {"No commit information available"}
@@ -1007,7 +1030,7 @@ proc layouttail {} {
1030 global idrowranges linesegends
1031
1032 set row $commitidx
1010 - set idlist $rowidlist($row)
1033 + set idlist [lindex $rowidlist $row]
1034 while {$idlist ne {}} {
1035 set col [expr {[llength $idlist] - 1}]
1036 set id [lindex $idlist $col]
@@ -1018,18 +1041,20 @@ proc layouttail {} {
1041 incr row
1042 set offs [ntimes $col 0]
1043 set idlist [lreplace $idlist $col $col]
1021 - set rowidlist($row) $idlist
1022 - set rowoffsets($row) $offs
1044 + lappend rowidlist $idlist
1045 + lappend rowoffsets $offs
1046 }
1047
1048 foreach id [array names idinlist] {
1049 addextraid $id $row
1027 - set rowidlist($row) [list $id]
1028 - set rowoffsets($row) 0
1050 + lset rowidlist $row [list $id]
1051 + lset rowoffsets $row 0
1052 makeuparrow $id 0 $row 0
1053 lappend linesegends($row) $id
1054 lappend idrowranges($id) $row
1055 incr row
1056 + lappend rowidlist {}
1057 + lappend rowoffsets {}
1058 }
1059 }
1060
@@ -1037,17 +1062,17 @@ proc insert_pad {row col npad} {
1062 global rowidlist rowoffsets
1063
1064 set pad [ntimes $npad {}]
1040 - set rowidlist($row) [eval linsert \$rowidlist($row) $col $pad]
1041 - set tmp [eval linsert \$rowoffsets($row) $col $pad]
1042 - set rowoffsets($row) [incrange $tmp [expr {$col + $npad}] [expr {-$npad}]]
1065 + lset rowidlist $row [eval linsert [list [lindex $rowidlist $row]] $col $pad]
1066 + set tmp [eval linsert [list [lindex $rowoffsets $row]] $col $pad]
1067 + lset rowoffsets $row [incrange $tmp [expr {$col + $npad}] [expr {-$npad}]]
1068 }
1069
1070 proc optimize_rows {row col endrow} {
1071 global rowidlist rowoffsets idrowranges
1072
1073 for {} {$row < $endrow} {incr row} {
1049 - set idlist $rowidlist($row)
1050 - set offs $rowoffsets($row)
1074 + set idlist [lindex $rowidlist $row]
1075 + set offs [lindex $rowoffsets $row]
1076 set haspad 0
1077 for {} {$col < [llength $offs]} {incr col} {
1078 if {[lindex $idlist $col] eq {}} {
@@ -1059,7 +1084,7 @@ proc optimize_rows {row col endrow} {
1084 set isarrow 0
1085 set x0 [expr {$col + $z}]
1086 set y0 [expr {$row - 1}]
1062 - set z0 [lindex $rowoffsets($y0) $x0]
1087 + set z0 [lindex $rowoffsets $y0 $x0]
1088 if {$z0 eq {}} {
1089 set id [lindex $idlist $col]
1090 if {[info exists idrowranges($id)] &&
@@ -1076,11 +1101,11 @@ proc optimize_rows {row col endrow} {
1101 }
1102 set z [lindex $offs $col]
1103 set x0 [expr {$col + $z}]
1079 - set z0 [lindex $rowoffsets($y0) $x0]
1104 + set z0 [lindex $rowoffsets $y0 $x0]
1105 } elseif {$z > 1 || ($z > 0 && $isarrow)} {
1106 set npad [expr {$z - 1 + $isarrow}]
1107 set y1 [expr {$row + 1}]
1083 - set offs2 $rowoffsets($y1)
1108 + set offs2 [lindex $rowoffsets $y1]
1109 set x1 -1
1110 foreach z $offs2 {
1111 incr x1
@@ -1088,7 +1113,7 @@ proc optimize_rows {row col endrow} {
1113 if {$x1 + $z > $col} {
1114 incr npad
1115 }
1091 - set rowoffsets($y1) [incrange $offs2 $x1 $npad]
1116 + lset rowoffsets $y1 [incrange $offs2 $x1 $npad]
1117 break
1118 }
1119 set pad [ntimes $npad {}]
@@ -1112,12 +1137,12 @@ proc optimize_rows {row col endrow} {
1137 }
1138 if {[incr col] < [llength $idlist]} {
1139 set y1 [expr {$row + 1}]
1115 - set offs2 $rowoffsets($y1)
1140 + set offs2 [lindex $rowoffsets $y1]
1141 set x1 -1
1142 foreach z $offs2 {
1143 incr x1
1144 if {$z eq {} || $x1 + $z < $col} continue
1120 - set rowoffsets($y1) [incrange $offs2 $x1 1]
1145 + lset rowoffsets $y1 [incrange $offs2 $x1 1]
1146 break
1147 }
1148 set idlist [linsert $idlist $col {}]
@@ -1126,8 +1151,8 @@ proc optimize_rows {row col endrow} {
1151 set offs [incrange $tmp $col -1]
1152 }
1153 }
1129 - set rowidlist($row) $idlist
1130 - set rowoffsets($row) $offs
1154 + lset rowidlist $row $idlist
1155 + lset rowoffsets $row $offs
1156 set col 0
1157 }
1158 }
@@ -1151,7 +1176,7 @@ proc drawlineseg {id i wid} {
1176 if {$startrow == $row} return
1177 assigncolor $id
1178 set coords {}
1154 - set col [lsearch -exact $rowidlist($row) $id]
1179 + set col [lsearch -exact [lindex $rowidlist $row] $id]
1180 if {$col < 0} {
1181 puts "oops: drawline: id $id not on row $row"
1182 return
@@ -1159,7 +1184,7 @@ proc drawlineseg {id i wid} {
1184 set lasto {}
1185 set ns 0
1186 while {1} {
1162 - set o [lindex $rowoffsets($row) $col]
1187 + set o [lindex $rowoffsets $row $col]
1188 if {$o eq {}} break
1189 if {$o ne $lasto} {
1190 # changing direction
@@ -1186,14 +1211,13 @@ proc drawlineseg {id i wid} {
1211 }
1212
1213 proc drawparentlinks {id row col olds wid} {
1189 - global rowoffsets rowidlist canv colormap lthickness
1214 + global rowidlist canv colormap lthickness
1215
1216 set row2 [expr {$row + 1}]
1217 set x [xc $row $col]
1218 set y [yc $row]
1219 set y2 [yc $row2]
1195 - set ids $rowidlist($row2)
1196 - set offs $rowidlist($row2)
1220 + set ids [lindex $rowidlist $row2]
1221 # rmx = right-most X coord used
1222 set rmx 0
1223 set wid [expr {$wid * $lthickness}]
@@ -1241,7 +1265,7 @@ proc drawlines {id xtra} {
1265 foreach child $children($id) {
1266 if {[info exists iddrawn($child)]} {
1267 set row $commitrow($child)
1244 - set col [lsearch -exact $rowidlist($row) $child]
1268 + set col [lsearch -exact [lindex $rowidlist $row] $child]
1269 if {$col >= 0} {
1270 drawparentlinks $child $row $col [list $id] $wid
1271 }
@@ -1266,7 +1290,7 @@ proc drawcmittext {id row col rmx} {
1290 -fill $ofill -outline black -width 1]
1291 $canv raise $t
1292 $canv bind $t <1> {selcanvline {} %x %y}
1269 - set xt [xc $row [llength $rowidlist($row)]]
1293 + set xt [xc $row [llength [lindex $rowidlist $row]]]
1294 if {$xt < $rmx} {
1295 set xt $rmx
1296 }
@@ -1290,12 +1314,12 @@ proc drawcmittext {id row col rmx} {
1314 }
1315
1316 proc drawcmitrow {row} {
1293 - global displayorder rowidlist rowoffsets
1317 + global displayorder rowidlist
1318 global idrowranges idrangedrawn iddrawn
1319 global commitinfo commitlisted parents numcommits
1320
1297 - if {![info exists rowidlist($row)]} return
1298 - foreach id $rowidlist($row) {
1321 + if {$row >= $numcommits} return
1322 + foreach id [lindex $rowidlist $row] {
1323 if {![info exists idrowranges($id)]} continue
1324 set i -1
1325 foreach {s e} $idrowranges($id) {
@@ -1314,7 +1338,7 @@ proc drawcmitrow {row} {
1338
1339 set id [lindex $displayorder $row]
1340 if {[info exists iddrawn($id)]} return
1317 - set col [lsearch -exact $rowidlist($row) $id]
1341 + set col [lsearch -exact [lindex $rowidlist $row] $id]
1342 if {$col < 0} {
1343 puts "oops, row $row id $id not in list"
1344 return
@@ -1442,15 +1466,6 @@ proc assigncolor {id} {
1466 set colormap($id) $c
1467 }
1468
1445 -proc initgraph {} {
1446 - global numcommits nextcolor linespc
1447 - global nchildren
1448 -
1449 - allcanvs delete all
1450 - set nextcolor 0
1451 - set numcommits 0
1452 -}
1453 -
1469 proc bindline {t id} {
1470 global canv
1471
@@ -1532,9 +1547,9 @@ proc checkcrossings {row endrow} {
1547
1548 for {} {$row < $endrow} {incr row} {
1549 set id [lindex $displayorder $row]
1535 - set i [lsearch -exact $rowidlist($row) $id]
1550 + set i [lsearch -exact [lindex $rowidlist $row] $id]
1551 if {$i < 0} continue
1537 - set idlist $rowidlist([expr {$row+1}])
1552 + set idlist [lindex $rowidlist [expr {$row+1}]]
1553 foreach p $parents($id) {
1554 set j [lsearch -exact $idlist $p]
1555 if {$j > 0} {
@@ -1552,7 +1567,7 @@ proc notecrossings {row id lo hi corner} {
1567 global rowidlist crossings cornercrossings
1568
1569 for {set i $lo} {[incr i] < $hi} {} {
1555 - set p [lindex $rowidlist($row) $i]
1570 + set p [lindex [lindex $rowidlist $row] $i]
1571 if {$p == {}} continue
1572 if {$i == $corner} {
1573 if {![info exists cornercrossings($id)]
@@ -1588,25 +1603,6 @@ proc xcoord {i level ln} {
1603 return $x
1604 }
1605
1591 -proc drawcommit {id reading} {
1592 - global phase todo nchildren nextupdate
1593 - global displayorder parents
1594 - global commitrow commitidx lineid
1595 -
1596 - if {$phase != "incrdraw"} {
1597 - set phase incrdraw
1598 - set displayorder {}
1599 - set todo {}
1600 - set commitidx 0
1601 - initlayout
1602 - initgraph
1603 - }
1604 - set commitrow($id) $commitidx
1605 - set lineid($commitidx) $id
1606 - incr commitidx
1607 - lappend displayorder $id
1608 -}
1609 -
1606 proc finishcommits {} {
1607 global phase
1608 global canv mainfont ctext maincursor textcursor
@@ -1674,7 +1670,7 @@ proc findmatches {f} {
1670
1671 proc dofind {} {
1672 global findtype findloc findstring markedmatches commitinfo
1677 - global numcommits lineid linehtag linentag linedtag
1673 + global numcommits displayorder linehtag linentag linedtag
1674 global mainfont namefont canv canv2 canv3 selectedline
1675 global matchinglines foundstring foundstrlen
1676
@@ -1705,7 +1701,7 @@ proc dofind {} {
1701 set didsel 0
1702 set fldtypes {Headline Author Date Committer CDate Comment}
1703 for {set l 0} {$l < $numcommits} {incr l} {
1708 - set id $lineid($l)
1704 + set id [lindex $displayorder $l]
1705 set info $commitinfo($id)
1706 set doesmatch 0
1707 foreach f $info ty $fldtypes {
@@ -1830,7 +1826,7 @@ proc stopfindproc {{done 0}} {
1826 proc findpatches {} {
1827 global findstring selectedline numcommits
1828 global findprocpid findprocfile
1833 - global finddidsel ctext lineid findinprogress
1829 + global finddidsel ctext displayorder findinprogress
1830 global findinsertpos
1831
1832 if {$numcommits == 0} return
@@ -1847,7 +1843,7 @@ proc findpatches {} {
1843 if {[incr l] >= $numcommits} {
1844 set l 0
1845 }
1850 - append inputids $lineid($l) "\n"
1846 + append inputids [lindex $displayorder $l] "\n"
1847 }
1848
1849 if {[catch {
@@ -1918,7 +1914,7 @@ proc insertmatch {l id} {
1914 }
1915
1916 proc findfiles {} {
1921 - global selectedline numcommits lineid ctext
1917 + global selectedline numcommits displayorder ctext
1918 global ffileline finddidsel parents nparents
1919 global findinprogress findstartline findinsertpos
1920 global treediffs fdiffid fdiffsneeded fdiffpos
@@ -1936,7 +1932,7 @@ proc findfiles {} {
1932 set diffsneeded {}
1933 set fdiffsneeded {}
1934 while 1 {
1939 - set id $lineid($l)
1935 + set id [lindex $displayorder $l]
1936 if {$findmergefiles || $nparents($id) == 1} {
1937 if {![info exists treediffs($id)]} {
1938 append diffsneeded "$id\n"
@@ -1965,7 +1961,7 @@ proc findfiles {} {
1961
1962 set finddidsel 0
1963 set findinsertpos end
1968 - set id $lineid($l)
1964 + set id [lindex $displayorder $l]
1965 . config -cursor watch
1966 settextcursor watch
1967 set findinprogress 1
@@ -2035,7 +2031,7 @@ proc donefilediff {} {
2031 proc findcont {id} {
2032 global findid treediffs parents nparents
2033 global ffileline findstartline finddidsel
2038 - global lineid numcommits matchinglines findinprogress
2034 + global displayorder numcommits matchinglines findinprogress
2035 global findmergefiles
2036
2037 set l $ffileline
@@ -2062,7 +2058,7 @@ proc findcont {id} {
2058 set l 0
2059 }
2060 if {$l == $findstartline} break
2065 - set id $lineid($l)
2061 + set id [lindex $displayorder $l]
2062 }
2063 stopfindproc
2064 if {!$finddidsel} {
@@ -2161,15 +2157,15 @@ proc appendwithlinks {text} {
2157
2158 proc selectline {l isnew} {
2159 global canv canv2 canv3 ctext commitinfo selectedline
2164 - global lineid linehtag linentag linedtag
2160 + global displayorder linehtag linentag linedtag
2161 global canvy0 linespc parents nparents children
2162 global cflist currentid sha1entry
2163 global commentend idtags linknum
2168 - global mergemax
2164 + global mergemax numcommits
2165
2166 $canv delete hover
2167 normalline
2172 - if {![info exists lineid($l)]} return
2168 + if {$l < 0 || $l >= $numcommits} return
2169 set y [expr {$canvy0 + $l * $linespc}]
2170 set ymax [lindex [$canv cget -scrollregion] 3]
2171 set ytop [expr {$y - $linespc - 1}]
@@ -2226,7 +2222,7 @@ proc selectline {l isnew} {
2222
2223 set selectedline $l
2224
2229 - set id $lineid($l)
2225 + set id [lindex $displayorder $l]
2226 set currentid $id
2227 $sha1entry delete 0 end
2228 $sha1entry insert 0 $id
@@ -2719,7 +2715,7 @@ proc sha1change {n1 n2 op} {
2715
2716 proc gotocommit {} {
2717 global sha1string currentid commitrow tagids
2722 - global lineid numcommits
2718 + global displayorder numcommits
2719
2720 if {$sha1string == {}
2721 || ([info exists currentid] && $sha1string == $currentid)} return
@@ -2730,8 +2726,8 @@ proc gotocommit {} {
2726 if {[regexp {^[0-9a-f]{4,39}$} $id]} {
2727 set matches {}
2728 for {set l 0} {$l < $numcommits} {incr l} {
2733 - if {[string match $id* $lineid($l)]} {
2734 - lappend matches $lineid($l)
2729 + if {[string match $id* [lindex $displayorder $l]]} {
2730 + lappend matches [lindex $displayorder $l]
2731 }
2732 }
2733 if {$matches ne {}} {
@@ -2948,15 +2944,15 @@ proc rowmenu {x y id} {
2944 }
2945
2946 proc diffvssel {dirn} {
2951 - global rowmenuid selectedline lineid
2947 + global rowmenuid selectedline displayorder
2948
2949 if {![info exists selectedline]} return
2950 if {$dirn} {
2955 - set oldid $lineid($selectedline)
2951 + set oldid [lindex $displayorder $selectedline]
2952 set newid $rowmenuid
2953 } else {
2954 set oldid $rowmenuid
2959 - set newid $lineid($selectedline)
2955 + set newid [lindex $displayorder $selectedline]
2956 }
2957 addtohistory [list doseldiff $oldid $newid]
2958 doseldiff $oldid $newid