aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-21 21:19:19 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-21 21:19:19 +0000
commitf5d88738f1cabc59a20285063be3d0d6e998c9bd (patch)
tree1102d94084112f7e0daf372c99f7b1798f393cf7 /apps
parent83a89cc17ed42bbed7a60f750d9f5e6e8c99c28b (diff)
Something I've been itching to do for a while now. A minor optimization in app_voicemail.
Since the dtable in base_encode always gets populated with the same values every time and never changes, make it static and const and only initialize it once. Also, there's no reason to define BASEMAXINLINE twice, so remove the redundant #define. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@94593 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_voicemail.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index b6a65ed04..ad4bf4619 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -197,7 +197,6 @@ static AST_LIST_HEAD_STATIC(vmstates, vmstate);
#define MAXMSG 100
#define MAXMSGLIMIT 9999
-#define BASEMAXINLINE 256
#define BASELINELEN 72
#define BASEMAXINLINE 256
#define eol "\r\n"
@@ -1793,7 +1792,10 @@ static int ochar(struct baseio *bio, int c, FILE *so)
static int base_encode(char *filename, FILE *so)
{
- unsigned char dtable[BASEMAXINLINE];
+ static const unsigned char dtable[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0',
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
int i,hiteof= 0;
FILE *fi;
struct baseio bio;
@@ -1806,22 +1808,6 @@ static int base_encode(char *filename, FILE *so)
return -1;
}
- for (i= 0; i<9; i++) {
- dtable[i]= 'A'+i;
- dtable[i+9]= 'J'+i;
- dtable[26+i]= 'a'+i;
- dtable[26+i+9]= 'j'+i;
- }
- for (i= 0; i<8; i++) {
- dtable[i+18]= 'S'+i;
- dtable[26+i+18]= 's'+i;
- }
- for (i= 0; i<10; i++) {
- dtable[52+i]= '0'+i;
- }
- dtable[62]= '+';
- dtable[63]= '/';
-
while (!hiteof){
unsigned char igroup[3], ogroup[4];
int c,n;