Skip to content
Snippets Groups Projects
Commit 905e5b7a authored by rswindell's avatar rswindell
Browse files

Eliminated unnecessary internal code and pointer index checking while importing

subs (no need to check newly-created subs for dupes) - eliminates exponential
importation time witnessed with large numbers (thousands) of message areas
being imported from a single file.
parent 1ae1cdd4
Branches
Tags
No related merge requests found
...@@ -126,6 +126,7 @@ void msgs_cfg() ...@@ -126,6 +126,7 @@ void msgs_cfg()
char tmp_code[16]; char tmp_code[16];
int j,k,l,q,s; int j,k,l,q,s;
int i,file,ptridx,n; int i,file,ptridx,n;
unsigned total_subs;
long ported; long ported;
sub_t tmpsub; sub_t tmpsub;
static grp_t savgrp; static grp_t savgrp;
...@@ -538,6 +539,8 @@ import into the current message group. ...@@ -538,6 +539,8 @@ import into the current message group.
uifc.msg("Open Failure"); uifc.msg("Open Failure");
break; } break; }
uifc.pop("Importing Areas..."); uifc.pop("Importing Areas...");
total_subs = cfg.total_subs; /* Save original number of subs */
ptridx = 0;
while(!feof(stream)) { while(!feof(stream)) {
if(!fgets(str,sizeof(str),stream)) break; if(!fgets(str,sizeof(str),stream)) break;
truncsp(str); truncsp(str);
...@@ -676,13 +679,13 @@ import into the current message group. ...@@ -676,13 +679,13 @@ import into the current message group.
|| tmpsub.qwkname[0]==0) || tmpsub.qwkname[0]==0)
continue; continue;
for(j=0;j<cfg.total_subs;j++) { for(j=0;j<total_subs;j++) {
if(cfg.sub[j]->grp!=i) if(cfg.sub[j]->grp!=i)
continue; continue;
if(!stricmp(cfg.sub[j]->code_suffix,tmpsub.code_suffix)) if(!stricmp(cfg.sub[j]->code_suffix,tmpsub.code_suffix))
break; } break; }
if(j==cfg.total_subs) { if(j==total_subs) {
j=cfg.total_subs;
if((cfg.sub=(sub_t **)realloc(cfg.sub if((cfg.sub=(sub_t **)realloc(cfg.sub
,sizeof(sub_t *)*(cfg.total_subs+1)))==NULL) { ,sizeof(sub_t *)*(cfg.total_subs+1)))==NULL) {
errormsg(WHERE,ERR_ALLOC,nulstr,cfg.total_subs+1); errormsg(WHERE,ERR_ALLOC,nulstr,cfg.total_subs+1);
...@@ -698,9 +701,9 @@ import into the current message group. ...@@ -698,9 +701,9 @@ import into the current message group.
} }
memset(cfg.sub[j],0,sizeof(sub_t)); } memset(cfg.sub[j],0,sizeof(sub_t)); }
if(!k) { if(!k) {
ptridx=cfg.sub[j]->ptridx; /* save original ptridx */ n=cfg.sub[j]->ptridx; /* save original ptridx */
memcpy(cfg.sub[j],&tmpsub,sizeof(sub_t)); memcpy(cfg.sub[j],&tmpsub,sizeof(sub_t));
cfg.sub[j]->ptridx=ptridx; /* restore original ptridx */ cfg.sub[j]->ptridx=n; /* restore original ptridx */
} else { } else {
cfg.sub[j]->grp=i; cfg.sub[j]->grp=i;
if(cfg.total_faddrs) if(cfg.total_faddrs)
...@@ -714,16 +717,17 @@ import into the current message group. ...@@ -714,16 +717,17 @@ import into the current message group.
cfg.sub[j]->maxmsgs=1000; cfg.sub[j]->maxmsgs=1000;
} }
if(j==cfg.total_subs) { /* adding new sub-board */ if(j==cfg.total_subs) { /* adding new sub-board */
for(ptridx=0;ptridx<USHRT_MAX;ptridx++) { for(;ptridx<USHRT_MAX;ptridx++) {
for(n=0;n<cfg.total_subs;n++) for(n=0;n<total_subs;n++)
if(cfg.sub[n]->ptridx==ptridx) if(cfg.sub[n]->ptridx==ptridx)
break; break;
if(n==cfg.total_subs) if(n==total_subs)
break; break;
} }
cfg.sub[j]->ptridx=ptridx; /* use new ptridx */ cfg.sub[j]->ptridx=ptridx; /* use new ptridx */
cfg.sub[j]->misc=tmpsub.misc; cfg.sub[j]->misc=tmpsub.misc;
cfg.total_subs++; cfg.total_subs++;
ptridx++; /* don't use the same ptridx for next sub */
} }
uifc.changes=1; uifc.changes=1;
ported++; ported++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment