aboutsummaryrefslogtreecommitdiffstats
path: root/src/charset.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-21 05:04:58 +0000
committerlloyd <[email protected]>2006-06-21 05:04:58 +0000
commitc16403753ec01c1ab4bba9e940cd31b9f8c4f24a (patch)
tree2f580070c09a53a111dfe05ca0283015ce78a852 /src/charset.cpp
parent268a09d7af9cb59f5a16b45c87c4890cbb36272d (diff)
Use a switch instead of repeated if statements in the char<->digit
conversion functions.
Diffstat (limited to 'src/charset.cpp')
-rw-r--r--src/charset.cpp46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/charset.cpp b/src/charset.cpp
index 3a28cce92..d988bb5ae 100644
--- a/src/charset.cpp
+++ b/src/charset.cpp
@@ -48,16 +48,19 @@ bool is_space(char c)
*************************************************/
byte char2digit(char c)
{
- if(c == '0') return 0;
- if(c == '1') return 1;
- if(c == '2') return 2;
- if(c == '3') return 3;
- if(c == '4') return 4;
- if(c == '5') return 5;
- if(c == '6') return 6;
- if(c == '7') return 7;
- if(c == '8') return 8;
- if(c == '9') return 9;
+ switch(c)
+ {
+ case '0': return 0;
+ case '1': return 1;
+ case '2': return 2;
+ case '3': return 3;
+ case '4': return 4;
+ case '5': return 5;
+ case '6': return 6;
+ case '7': return 7;
+ case '8': return 8;
+ case '9': return 9;
+ }
throw Invalid_Argument("char2digit: Input is not a digit character");
}
@@ -67,16 +70,19 @@ byte char2digit(char c)
*************************************************/
char digit2char(byte b)
{
- if(b == 0) return '0';
- if(b == 1) return '1';
- if(b == 2) return '2';
- if(b == 3) return '3';
- if(b == 4) return '4';
- if(b == 5) return '5';
- if(b == 6) return '6';
- if(b == 7) return '7';
- if(b == 8) return '8';
- if(b == 9) return '9';
+ switch(b)
+ {
+ case 0: return '0';
+ case 1: return '1';
+ case 2: return '2';
+ case 3: return '3';
+ case 4: return '4';
+ case 5: return '5';
+ case 6: return '6';
+ case 7: return '7';
+ case 8: return '8';
+ case 9: return '9';
+ }
throw Invalid_Argument("digit2char: Input is not a digit");
}