diff options
author | martinko | 2012-10-04 13:02:11 +0000 |
---|---|---|
committer | martinko | 2012-10-04 13:02:11 +0000 |
commit | 0c8c998e0941d080cbd6107a904c719ce78a9982 (patch) | |
tree | 9bb67808f5c9213c93324ad7928dbff9bfabc729 /python/skytools/scripting.py | |
parent | f8d90af0912db0a2ed29aa5e8fb912be3ab309a6 (diff) |
skytools.scripting: speed up stat counters
Diffstat (limited to 'python/skytools/scripting.py')
-rw-r--r-- | python/skytools/scripting.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py index 5efae8d6..12a72da9 100644 --- a/python/skytools/scripting.py +++ b/python/skytools/scripting.py @@ -462,9 +462,9 @@ class BaseScript(object): def stat_increase(self, key, increase = 1): """Increases a stat value.""" - if key in self.stat_dict: + try: self.stat_dict[key] += increase - else: + except KeyError: self.stat_dict[key] = increase def send_stats(self): @@ -472,7 +472,7 @@ class BaseScript(object): res = [] for k, v in self.stat_dict.items(): - res.append("%s: %s" % (k, str(v))) + res.append("%s: %s" % (k, v)) if len(res) == 0: return |