ref: e9b8b9f929b637fbb9b42d1720f702e8779226a0
parent: 63eb975ed2b11a64eef00161984643bb3271548d
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Jul 3 11:04:24 EDT 2014
tr: do not call dict_put() unnecessarily
--- a/tr.c
+++ b/tr.c
@@ -555,12 +555,13 @@
void cmap_add(char *c1, char *c2)
{
int i = dict_get(&cmap, c1);
- if (i < 0 && cmap_n < NCMAPS)
- i = cmap_n++;
if (i >= 0) {
- strcpy(cmap_src[i], c1);
strcpy(cmap_dst[i], c2);
- dict_put(&cmap, cmap_src[i], i);
+ } else if (cmap_n < NCMAPS) {
+ strcpy(cmap_src[cmap_n], c1);
+ strcpy(cmap_dst[cmap_n], c2);
+ dict_put(&cmap, cmap_src[cmap_n], cmap_n);
+ cmap_n++;
}
}