git-gui: Delay searching for 'nice' until its really asked for
Not every caller of 'git' or 'git_pipe' wants to use nice to lower the priority of the process its executing. In many cases we may never use the nice process to launch git. So we can avoid searching our $PATH to locate a suitable nice if we'll never actually use it. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jul 17, 2007 at 22:31 UTC
6f62b4f782c51bdf0dfdef3da5b5049c9006ff70
1 file changed
+15
-13
git-gui.sh
+15
-13
@@ -367,16 +367,25 @@ proc _which {what} {
367
return {}
368
}
369
370
+proc _lappend_nice {cmd_var} {
371
+ global _nice
372
+ upvar $cmd_var cmd
373
+
374
+ if {![info exists _nice]} {
375
+ set _nice [_which nice]
376
+ }
377
+ if {$_nice ne {}} {
378
+ lappend cmd $_nice
379
+ }
380
+}
381
+
382
proc git {args} {
383
set opt [list exec]
384
385
while {1} {
386
switch -- [lindex $args 0] {
387
--nice {
376
- global _nice
377
- if {$_nice ne {}} {
378
- lappend opt $_nice
379
- }
388
+ _lappend_nice opt
389
}
390
391
default {
@@ -424,10 +433,7 @@ proc git_read {args} {
433
while {1} {
434
switch -- [lindex $args 0] {
435
--nice {
427
- global _nice
428
- if {$_nice ne {}} {
429
- lappend opt $_nice
430
- }
436
+ _lappend_nice opt
437
}
438
439
--stderr {
@@ -455,10 +461,7 @@ proc git_write {args} {
461
while {1} {
462
switch -- [lindex $args 0] {
463
--nice {
458
- global _nice
459
- if {$_nice ne {}} {
460
- lappend opt $_nice
461
- }
464
+ _lappend_nice opt
465
}
466
467
default {
@@ -525,7 +528,6 @@ if {$_git eq {}} {
528
error_popup "Cannot find git in PATH."
529
exit 1
530
}
528
-set _nice [_which nice]
531
532
######################################################################
533
##