Speed optimisations.

This commit is contained in:
Ianos Gnatiuc 2007-01-11 22:26:06 +00:00
parent c58810fefe
commit 57563ba911
6 changed files with 245 additions and 189 deletions

View File

@ -79,4 +79,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
AMDCaProjectFile = F:\work\_db_cvs\golded+\windows\bin\release\win32\CodeAnalyst\golded.caw
EndGlobalSection
EndGlobal

View File

@ -69,11 +69,15 @@ void AreaList::SortAreaGroup(const char* options, int beginarea, int endarea) {
// ------------------------------------------------------------------
// Rename an echoid
void RenameArea(char* echoid) {
void RenameArea(char* echoid)
{
std::vector<EchoRen>::iterator n = CFG->arearename.begin();
std::vector<EchoRen>::iterator end = CFG->arearename.end();
std::vector<EchoRen>::iterator n;
for(n = CFG->arearename.begin(); n != CFG->arearename.end(); n++) {
if(strieql(echoid, n->from.c_str())) {
for (; n != end; n++)
{
if (strieql(echoid, n->from.c_str()))
{
strxcpy(echoid, n->to.c_str(), sizeof(Echo));
break;
}
@ -84,20 +88,29 @@ void RenameArea(char* echoid) {
// ------------------------------------------------------------------
// Check if the echoid is on the exclusion list
bool CheckExcl(char* echoid) {
gstrarray::iterator n, x;
for(n = CFG->areaexcl.begin(); n != CFG->areaexcl.end(); n++) {
if(strwild(echoid, n->c_str())) {
bool CheckExcl(char* echoid)
{
gstrarray::iterator n = CFG->areaexcl.begin();
gstrarray::iterator end1 = CFG->areaexcl.end();
for (; n != end1; n++)
{
if (strwild(echoid, n->c_str()))
{
// Found excl, now check for incl
for(x = CFG->areaincl.begin(); x != CFG->areaincl.end(); x++)
if(strwild(echoid, x->c_str()))
gstrarray::iterator x = CFG->areaincl.begin();
gstrarray::iterator end2 = CFG->areaincl.end();
for (; x != end2; x++)
{
if (strwild(echoid, x->c_str()))
return false;
}
return true; // Echoid is excluded
}
}
return false;
}
@ -105,19 +118,27 @@ bool CheckExcl(char* echoid) {
// ------------------------------------------------------------------
// Check if the echo is email or news
void CheckEMailOrNews(char* echoid, uint& type) {
void CheckEMailOrNews(char* echoid, uint& type)
{
gstrarray::iterator i = CFG->areaisemail.begin();
gstrarray::iterator end = CFG->areaisemail.end();
gstrarray::iterator i;
for(i = CFG->areaisemail.begin(); i != CFG->areaisemail.end(); i++) {
if(strwild(echoid, i->c_str())) {
for (; i != end; i++)
{
if (strwild(echoid, i->c_str()))
{
type = GMB_EMAIL | GMB_NET;
break;
}
}
for(i = CFG->areaisnews.begin(); i != CFG->areaisnews.end(); i++) {
if(strwild(echoid, i->c_str())) {
i = CFG->areaisnews.begin();
end = CFG->areaisnews.end();
for(; i != end; i++)
{
if (strwild(echoid, i->c_str()))
{
type = GMB_NEWSGROUP | GMB_ECHO;
break;
}
@ -298,14 +319,19 @@ void AreaList::AddNewArea(AreaCfg* aa)
// Check if we already have the area (dup echoid or path)
int _currarea = 0;
area_iterator ap;
for(ap = idx.begin(); ap != idx.end(); ap++) {
area_iterator ap = idx.begin();
area_iterator end = idx.end();
for (; ap != end; ap++)
{
++_currarea;
int eq_echoid = strieql(aa->echoid, (*ap)->echoid());
if(eq_echoid) {
if (eq_echoid)
{
newarea = false;
if(not (*ap)->isseparator()) {
if(strblank((*ap)->desc()))
if (not (*ap)->isseparator())
{
if (strblank((*ap)->desc()))
strxcpy(desc, aa->desc, sizeof(desc));
}
break;
@ -346,14 +372,22 @@ void AreaList::AddNewArea(AreaCfg* aa)
}
// Add aka if not found
if(aa->aka.net) {
if (aa->aka.net)
{
bool found = false;
for(std::vector<gaka>::iterator i = CFG->aka.begin(); i != CFG->aka.end(); i++)
if(aa->aka == i->addr) {
std::vector<gaka>::iterator i = CFG->aka.begin();
std::vector<gaka>::iterator end = CFG->aka.end();
for (; i != end; i++)
{
if (aa->aka == i->addr)
{
found = true;
break;
}
if(not found) // Then add it
}
if (not found) // Then add it
CfgAddress(aa->aka.make_string(buf)); // Add the aka
}
else {
@ -889,11 +923,16 @@ void AreaList::ReadEcholist(char* val)
else
desc = NULL;
}
for(area_iterator ap = idx.begin(); ap != idx.end(); ap++) {
if(strieql(key, (*ap)->echoid())) {
area_iterator ap = idx.begin();
area_iterator end = idx.end();
for (; ap != end; ap++)
{
if (strieql(key, (*ap)->echoid()))
{
(*ap)->set_groupid(g_toupper(*grp));
if(desc)
(*ap)->set_desc(desc);
if (desc) (*ap)->set_desc(desc);
break;
}
}
@ -904,8 +943,14 @@ void AreaList::ReadEcholist(char* val)
tok(&desc, &val);
else
desc = val;
for(area_iterator ap = idx.begin(); ap != idx.end(); ap++) {
if(strieql(key, (*ap)->echoid())) {
area_iterator ap = idx.begin();
area_iterator end = idx.end();
for (; ap != end; ap++)
{
if (strieql(key, (*ap)->echoid()))
{
(*ap)->set_desc(desc);
break;
}
@ -927,13 +972,20 @@ void AreaList::GetAreaDesc(char* val) {
// Get echoid and find area
getkeyval(&key, &val);
for(area_iterator ap = idx.begin(); ap != idx.end(); ap++) {
if(strieql(key, (*ap)->echoid())) {
area_iterator ap = idx.begin();
area_iterator end = idx.end();
for (; ap != end; ap++)
{
if (strieql(key, (*ap)->echoid()))
{
aa = *ap;
break;
}
}
if(aa == NULL) // Not found, ignore
if (aa == NULL) // Not found, ignore
return;
// Get description
@ -1015,16 +1067,19 @@ Area::~Area() {
// ------------------------------------------------------------------
char* MapPath(char* map, bool reverse) {
char* MapPath(char* map, bool reverse)
{
Path buf, cmap;
strxcpy(cmap, map, sizeof(Path));
if(reverse)
strchg(cmap, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR);
std::vector< std::pair<std::string, std::string> >::iterator i;
for(i = CFG->mappath.begin(); i != CFG->mappath.end(); i++) {
std::vector< std::pair<std::string, std::string> >::iterator i = CFG->mappath.begin();
std::vector< std::pair<std::string, std::string> >::iterator end = CFG->mappath.end();
for (i; i != end; i++)
{
const char* p = reverse ? i->second.c_str() : i->first.c_str();
const char* q = reverse ? i->first.c_str() : i->second.c_str();
if(strnieql(cmap, p, strlen(p))) {
@ -1051,15 +1106,19 @@ char* MapPath(char* map, bool reverse) {
// ------------------------------------------------------------------
// Set area origin
int AreaCfgBase::setorigin(std::string& _origin) {
if(not strblank(_origin.c_str())) {
int AreaCfgBase::setorigin(std::string& _origin)
{
if (not strblank(_origin.c_str()))
{
// Check if it already exists
gstrarray::iterator n;
for(n = CFG->origin.begin(), originno = 0; n != CFG->origin.end(); originno++, n++)
if(*n == _origin)
gstrarray::iterator n = CFG->origin.begin();
gstrarray::iterator end = CFG->origin.end();
for (originno = 0; n != end; originno++, n++)
{
if (*n == _origin)
return originno;
}
// Not found, so add it
CfgOrigin(_origin.c_str());

View File

@ -506,9 +506,10 @@ std::string &strtrim(std::string &str)
{
if (!str.empty())
{
std::string::iterator begin = str.begin();
std::string::iterator trail = str.end();
while(trail != str.begin())
while (trail != begin)
{
--trail;
if (not isspace(*trail) and not iscntrl(*trail))

View File

@ -219,7 +219,7 @@ protected:
#endif
#ifndef GCFG_NOFIDOCONF
AreaCfg echoareadefaults;
bool ReadHPTLine(gfile &f, std::string* s, bool add=false, int state=0);
bool ReadHPTLine(gfile &f, std::string& str);
void ReadHPTFile(char* path, char* file, char* origin, int group);
#endif
#ifndef GCFG_NOIMAIL

View File

@ -43,60 +43,50 @@ static char comment_char = '#';
// ------------------------------------------------------------------
bool gareafile::ReadHPTLine(gfile &f, std::string* s, bool add, int state)
bool gareafile::ReadHPTLine(gfile &f, std::string& str)
{
std::string str;
char buf[81];
char buf[1024];
if (!f.Fgets(buf, 81)) return false; // eof
if (!f.Fgets(buf, ARRAYSIZE(buf)))
return false; // eof
str = buf;
if (buf[strlen(buf)-1] != '\n')
if (!str.empty() && (*(str.end() - 1) != '\n'))
{
while (f.Fgets(buf, 81))
while (f.Fgets(buf, ARRAYSIZE(buf)))
{
str += buf;
if (buf[strlen(buf)-1] == '\n')
if (*(str.end() - 1) == '\n')
break;
}
}
std::string::iterator ptr = str.begin();
std::string::iterator end = str.end();
bool state = false;
// state 0: normal state
// 1: between ""
// 2: end
// 3: whitespace
while((ptr != str.end()) and (state != 2)) {
if(*ptr == comment_char) {
if(state != 1) {
str.erase(ptr, str.end());
state = 2;
continue;
for (; ptr != end; ptr++)
{
if (comment_char == *ptr)
{
if (!state)
{
str.erase(ptr, end);
break;
}
}
else {
switch(*ptr) {
case '\"':
state = (state == 1) ? 0 : 1;
break;
default:
break;
}
else if ('\"' == *ptr)
{
state = !state;
}
++ptr;
}
while(not str.empty() and ((*(str.end()-1) == '\n') or (*(str.end()-1) == '\r')))
str.erase(str.end()-1);
const char *p = strskip_wht(str.c_str());
if(add)
*s += p;
else
*s = p;
strltrim(strtrim(str));
return true;
}
@ -195,10 +185,10 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
aa.groupid = group;
std::string s;
while (ReadHPTLine(fp, &s))
while (ReadHPTLine(fp, s))
{
if(not s.empty()) {
if (not s.empty())
{
char *alptr = throw_xstrdup(s.c_str());
char *ptr = alptr;
@ -206,64 +196,64 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
char* val = ptr;
gettok(&key, &val);
switch (strCrc16(key))
{
case CRC_SET:
if (strchg(val, '[', '%') != 0)
strchg(val, ']', '%');
putenv(val);
break;
{
case CRC_SET:
if (strchg(val, '[', '%') != 0)
strchg(val, ']', '%');
putenv(val);
break;
case CRC_VERSION:
case CRC_VERSION:
{
int ver_maj, ver_min;
sscanf(val, "%d.%d", &ver_maj, &ver_min);
if (((ver_maj << 16) + ver_min) > 0x00010009)
{
int ver_maj, ver_min;
sscanf(val, "%d.%d", &ver_maj, &ver_min);
if (((ver_maj << 16) + ver_min) > 0x00010009)
{
STD_PRINTNL("* Error: Unknown fidoconfig version " << ver_maj << '.' << ver_min << " - Skipping.");
throw_xfree(alptr);
goto skip_config;
}
STD_PRINTNL("* Error: Unknown fidoconfig version " << ver_maj << '.' << ver_min << " - Skipping.");
throw_xfree(alptr);
goto skip_config;
}
break;
case CRC_ADDRESS:
CfgAddress(val);
break;
case CRC_SYSOP:
CfgUsername(val);
break;
case CRC_INCLUDE:
strxcpy(buf2, val, sizeof(buf2));
if(strchg(buf2, '[', '%') != 0)
strchg(buf2, ']', '%');
MakePathname(buf2, path, buf2);
ReadHPTFile(path, buf2, origin, group);
break;
case CRC_COMMENTCHAR:
if((strlen(val) == 3) and (val[0] == val[2]) and strpbrk(val, "\'\""))
comment_char = val[1];
else if(*val)
comment_char = val[0];
break;
case CRC_NETAREA:
case CRC_NETMAILAREA:
aa.type = GMB_NET;
break;
case CRC_LOCALAREA:
case CRC_DUPEAREA:
case CRC_BADAREA:
aa = echoareadefaults;
aa.type = GMB_LOCAL;
break;
case CRC_ECHOAREA:
aa = echoareadefaults;
aa.type = GMB_ECHO;
break;
case CRC_ECHOAREADEFAULTS:
echoareadefaults.reset();
aa.type = GMB_DEFAULT;
aa.basetype = fidomsgtype;
aa.groupid = group;
break;
}
break;
case CRC_ADDRESS:
CfgAddress(val);
break;
case CRC_SYSOP:
CfgUsername(val);
break;
case CRC_INCLUDE:
strxcpy(buf2, val, sizeof(buf2));
if(strchg(buf2, '[', '%') != 0)
strchg(buf2, ']', '%');
MakePathname(buf2, path, buf2);
ReadHPTFile(path, buf2, origin, group);
break;
case CRC_COMMENTCHAR:
if((strlen(val) == 3) and (val[0] == val[2]) and strpbrk(val, "\'\""))
comment_char = val[1];
else if(*val)
comment_char = val[0];
break;
case CRC_NETAREA:
case CRC_NETMAILAREA:
aa.type = GMB_NET;
break;
case CRC_LOCALAREA:
case CRC_DUPEAREA:
case CRC_BADAREA:
aa = echoareadefaults;
aa.type = GMB_LOCAL;
break;
case CRC_ECHOAREA:
aa = echoareadefaults;
aa.type = GMB_ECHO;
break;
case CRC_ECHOAREADEFAULTS:
echoareadefaults.reset();
aa.type = GMB_DEFAULT;
aa.basetype = fidomsgtype;
aa.groupid = group;
break;
}
if(aa.type != GMB_NONE) {
@ -283,71 +273,73 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
}
// If not pass-through
if(not strieql("Passthrough", key)) {
if(strchg(key, '[', '%') != 0)
if (not strieql("Passthrough", key))
{
if (strchg(key, '[', '%') != 0)
strchg(key, ']', '%');
aa.setpath(key);
gettok(&key, &val);
while((*key == '-') or strieql(key, "Squish") or strieql(key, "Jam") or strieql(key, "MSG")) {
if(strieql(key, "Squish"))
aa.basetype = "SQUISH";
else if(strieql(key, "Jam"))
aa.basetype = "JAM";
else if(strieql(key, "MSG"))
aa.basetype = fidomsgtype;
else {
for (;;)
{
if (*key == '-')
{
char *opt = key + 1;
if(strieql(opt, "p") or strieql(opt, "$m")
if (strieql(opt, "a"))
{
gettok(&key, &val);
CfgAddress(key);
aa.aka.set(key);
}
else if (strieql(opt, "g"))
{
gettok(&key, &val);
if (isdigit(*key))
aa.groupid = 0x8000 + atoi(key);
else if (g_isalpha(*key))
aa.groupid = g_toupper(*key);
}
else if (strieql(opt, "d"))
{
gettok(&key, &val);
aa.setdesc(key);
}
else if (strieql(opt, "pass"))
{
aa.type = GMB_NONE;
break;
}
else if (strieql(opt, "p") or strieql(opt, "$m")
or strieql(opt, "lr") or strieql(opt, "lw")
or strieql(opt, "dupeCheck") or strieql(opt, "dupehistory")
or strieql(opt, "r") or strieql(opt, "w")
or strieql(opt, "l") or strieql(opt, "fperm")
or strieql(opt, "fowner") or strnieql(opt, "sbadd(", 6)
or strnieql(opt, "sbign(", 6)) {
or strnieql(opt, "sbign(", 6))
{
gettok(&key, &val);
}
else if(strieql(opt, "a")) {
gettok(&key, &val);
CfgAddress(key);
aa.aka.set(key);
}
else if(strieql(opt, "h") or strieql(opt, "manual")
or strieql(opt, "nopause") or strieql(opt, "mandatory")
or strieql(opt, "dosfile") or strieql(opt, "ccoff")
or strieql(opt, "b") or strieql(opt, "tinysb")
or strieql(opt, "killsb") or strieql(opt, "keepunread")
or strieql(opt, "killread") or strieql(opt, "h")
or strieql(opt, "nolink") or strieql(opt, "debug")
or strieql(opt, "nopack") or strieql(opt, "keepsb")
or strieql(opt, "$") or strieql(opt, "0")) {
}
else if(strieql(opt, "g")) {
gettok(&key, &val);
if(isdigit(*key))
aa.groupid = 0x8000+atoi(key);
else if(g_isalpha(*key))
aa.groupid = g_toupper(*key);
}
else if (strieql(opt, "d")) {
gettok(&key, &val);
aa.setdesc(key);
}
else if (strieql(opt, "pass")) {
aa.type = GMB_NONE;
break;
}
//else if(strieql(opt, "h") or strieql(opt, "manual")
// or strieql(opt, "nopause") or strieql(opt, "mandatory")
// or strieql(opt, "dosfile") or strieql(opt, "ccoff")
// or strieql(opt, "b") or strieql(opt, "tinysb")
// or strieql(opt, "killsb") or strieql(opt, "keepunread")
// or strieql(opt, "killread") or strieql(opt, "h")
// or strieql(opt, "nolink") or strieql(opt, "debug")
// or strieql(opt, "nopack") or strieql(opt, "keepsb")
// or strieql(opt, "$") or strieql(opt, "0"))
//{
//}
}
else if (strieql(key, "Squish")) aa.basetype = "SQUISH";
else if (strieql(key, "Jam" )) aa.basetype = "JAM";
else if (strieql(key, "MSG" )) aa.basetype = fidomsgtype;
else
{
break;
}
gettok(&key, &val);

View File

@ -89,6 +89,7 @@
SuppressStartupBanner="true"
GenerateManifest="true"
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="false"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"