gitk: Make commitdata an array rather than a list
This turns out to be slightly simpler and faster, and will make things a little easier when we do multiple view support. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Mar 18, 2006 at 10:04 UTC
f7a3e8d254bf0034edfacd5aaf6e13ce2ed58d19
1 file changed
+10
-17
gitk
+10
-17
@@ -35,7 +35,6 @@ proc parse_args {rargs} {
35
proc start_rev_list {rlargs} {
36
global startmsecs nextupdate ncmupdate
37
global commfd leftover tclencoding datemode
38
- global commitdata
38
39
set startmsecs [clock clicks -milliseconds]
40
set nextupdate [expr {$startmsecs + 100}]
@@ -53,7 +52,6 @@ proc start_rev_list {rlargs} {
52
exit 1
53
}
54
set leftover {}
56
- set commitdata {}
55
fconfigure $commfd -blocking 0 -translation lf
56
if {$tclencoding != {}} {
57
fconfigure $commfd -encoding $tclencoding
@@ -137,8 +135,8 @@ proc getcommitlines {commfd} {
135
set id [lindex $ids 0]
136
set olds [lrange $ids 1 end]
137
set commitlisted($id) 1
140
- updatechildren $id [lrange $ids 1 end]
141
- lappend commitdata [string range $cmit [expr {$j + 1}] end]
138
+ updatechildren $id $olds
139
+ set commitdata($id) [string range $cmit [expr {$j + 1}] end]
140
set commitrow($id) $commitidx
141
incr commitidx
142
lappend displayorder $id
@@ -266,15 +264,11 @@ proc parsecommit {id contents listed} {
264
$comname $comdate $comment]
265
}
266
269
-proc getcommit {id {row {}}} {
270
- global commitdata commitrow commitinfo nparents
267
+proc getcommit {id} {
268
+ global commitdata commitinfo nparents
269
272
- if {$row eq {}} {
273
- if {![info exists commitrow($id)]} {return 0}
274
- set row $commitrow($id)
275
- }
276
- if {$row < [llength $commitdata]} {
277
- parsecommit $id [lindex $commitdata $row] 1
270
+ if {[info exists commitdata($id)]} {
271
+ parsecommit $id $commitdata($id) 1
272
} else {
273
readcommit $id
274
if {![info exists commitinfo($id)]} {
@@ -1341,7 +1335,6 @@ proc drawcmitrow {row} {
1335
global displayorder rowidlist
1336
global idrowranges idrangedrawn iddrawn
1337
global commitinfo commitlisted parents numcommits
1344
- global commitdata
1338
1339
if {$row >= $numcommits} return
1340
foreach id [lindex $rowidlist $row] {
@@ -1369,7 +1362,7 @@ proc drawcmitrow {row} {
1362
return
1363
}
1364
if {![info exists commitinfo($id)]} {
1372
- getcommit $id $row
1365
+ getcommit $id
1366
}
1367
assigncolor $id
1368
if {[info exists commitlisted($id)] && [info exists parents($id)]
@@ -1723,7 +1716,8 @@ proc dofind {} {
1716
set didsel 0
1717
set fldtypes {Headline Author Date Committer CDate Comment}
1718
set l -1
1726
- foreach d $commitdata {
1719
+ foreach id $displayorder {
1720
+ set d $commitdata($id)
1721
incr l
1722
if {$findtype == "Regexp"} {
1723
set doesmatch [regexp $foundstring $d]
@@ -1733,9 +1727,8 @@ proc dofind {} {
1727
set doesmatch [string match $matchstring $d]
1728
}
1729
if {!$doesmatch} continue
1736
- set id [lindex $displayorder $l]
1730
if {![info exists commitinfo($id)]} {
1738
- getcommit $id $l
1731
+ getcommit $id
1732
}
1733
set info $commitinfo($id)
1734
set doesmatch 0