Mercurial > hg
comparison contrib/hgk @ 24531:18ee81b37928
hgk: use switch instead of a less efficient if/elseif/if
author | Andrew Shadura <andrew@shadura.me> |
---|---|
date | Sun, 29 Mar 2015 19:15:04 +0200 |
parents | 2ace3b77aaef |
children | ce8dd4fd2d5d |
comparison
equal
deleted
inserted
replaced
24530:2ace3b77aaef | 24531:18ee81b37928 |
---|---|
373 set line [split $line] | 373 set line [split $line] |
374 if {$line == {}} { | 374 if {$line == {}} { |
375 set inhdr 0 | 375 set inhdr 0 |
376 } else { | 376 } else { |
377 set tag [lindex $line 0] | 377 set tag [lindex $line 0] |
378 if {$tag == "author"} { | 378 switch -- $tag "author" { |
379 set x [expr {[llength $line] - 2}] | 379 set x [expr {[llength $line] - 2}] |
380 set audate [lindex $line $x] | 380 set audate [lindex $line $x] |
381 set auname [join [lrange $line 1 [expr {$x - 1}]]] | 381 set auname [join [lrange $line 1 [expr {$x - 1}]]] |
382 } elseif {$tag == "committer"} { | 382 } "committer" { |
383 set x [expr {[llength $line] - 2}] | 383 set x [expr {[llength $line] - 2}] |
384 set comdate [lindex $line $x] | 384 set comdate [lindex $line $x] |
385 set comname [join [lrange $line 1 [expr {$x - 1}]]] | 385 set comname [join [lrange $line 1 [expr {$x - 1}]]] |
386 } elseif {$tag == "revision"} { | 386 } "revision" { |
387 set rev [lindex $line 1] | 387 set rev [lindex $line 1] |
388 } elseif {$tag == "branch"} { | 388 } "branch" { |
389 set branch [join [lrange $line 1 end]] | 389 set branch [join [lrange $line 1 end]] |
390 } elseif {$tag == "bookmark"} { | 390 } "bookmark" { |
391 set bookmark [join [lrange $line 1 end]] | 391 set bookmark [join [lrange $line 1 end]] |
392 } elseif {$tag == "obsolete"} { | 392 } "obsolete" { |
393 set obsolete($id) "" | 393 set obsolete($id) "" |
394 } elseif {$tag == "phase"} { | 394 } "phase" { |
395 set phase [lindex $line 1 end] | 395 set phase [lindex $line 1 end] |
396 } | 396 } |
397 } | 397 } |
398 } else { | 398 } else { |
399 if {$comment == {}} { | 399 if {$comment == {}} { |
400 set headline [string trim $line] | 400 set headline [string trim $line] |
401 } else { | 401 } else { |