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 GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
AMDCaProjectFile = F:\work\_db_cvs\golded+\windows\bin\release\win32\CodeAnalyst\golded.caw
EndGlobalSection
EndGlobal EndGlobal

View File

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

View File

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

View File

@ -219,7 +219,7 @@ protected:
#endif #endif
#ifndef GCFG_NOFIDOCONF #ifndef GCFG_NOFIDOCONF
AreaCfg echoareadefaults; 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); void ReadHPTFile(char* path, char* file, char* origin, int group);
#endif #endif
#ifndef GCFG_NOIMAIL #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[1024];
char buf[81];
if (!f.Fgets(buf, 81)) return false; // eof if (!f.Fgets(buf, ARRAYSIZE(buf)))
return false; // eof
str = buf; 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; str += buf;
if (buf[strlen(buf)-1] == '\n') if (*(str.end() - 1) == '\n')
break; break;
} }
} }
std::string::iterator ptr = str.begin(); std::string::iterator ptr = str.begin();
std::string::iterator end = str.end();
bool state = false;
// state 0: normal state // state 0: normal state
// 1: between "" // 1: between ""
// 2: end // 2: end
// 3: whitespace // 3: whitespace
while((ptr != str.end()) and (state != 2)) { for (; ptr != end; ptr++)
if(*ptr == comment_char) { {
if(state != 1) { if (comment_char == *ptr)
str.erase(ptr, str.end()); {
state = 2; if (!state)
continue; {
} str.erase(ptr, end);
}
else {
switch(*ptr) {
case '\"':
state = (state == 1) ? 0 : 1;
break;
default:
break; break;
} }
} }
++ptr; else if ('\"' == *ptr)
{
state = !state;
}
} }
while(not str.empty() and ((*(str.end()-1) == '\n') or (*(str.end()-1) == '\r'))) strltrim(strtrim(str));
str.erase(str.end()-1);
const char *p = strskip_wht(str.c_str());
if(add)
*s += p;
else
*s = p;
return true; return true;
} }
@ -195,10 +185,10 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
aa.groupid = group; aa.groupid = group;
std::string s; 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 *alptr = throw_xstrdup(s.c_str());
char *ptr = alptr; char *ptr = alptr;
@ -283,54 +273,28 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
} }
// If not pass-through // If not pass-through
if(not strieql("Passthrough", key)) { if (not strieql("Passthrough", key))
{
if (strchg(key, '[', '%') != 0) if (strchg(key, '[', '%') != 0)
strchg(key, ']', '%'); strchg(key, ']', '%');
aa.setpath(key); aa.setpath(key);
gettok(&key, &val); gettok(&key, &val);
while((*key == '-') or strieql(key, "Squish") or strieql(key, "Jam") or strieql(key, "MSG")) { for (;;)
{
if(strieql(key, "Squish")) if (*key == '-')
aa.basetype = "SQUISH"; {
else if(strieql(key, "Jam"))
aa.basetype = "JAM";
else if(strieql(key, "MSG"))
aa.basetype = fidomsgtype;
else {
char *opt = key + 1; char *opt = key + 1;
if(strieql(opt, "p") or strieql(opt, "$m") if (strieql(opt, "a"))
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)) {
gettok(&key, &val);
}
else if(strieql(opt, "a")) {
gettok(&key, &val); gettok(&key, &val);
CfgAddress(key); CfgAddress(key);
aa.aka.set(key); aa.aka.set(key);
} }
else if(strieql(opt, "h") or strieql(opt, "manual") else if (strieql(opt, "g"))
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); gettok(&key, &val);
if (isdigit(*key)) if (isdigit(*key))
@ -338,16 +302,44 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
else if (g_isalpha(*key)) else if (g_isalpha(*key))
aa.groupid = g_toupper(*key); aa.groupid = g_toupper(*key);
} }
else if (strieql(opt, "d")) { else if (strieql(opt, "d"))
{
gettok(&key, &val); gettok(&key, &val);
aa.setdesc(key); aa.setdesc(key);
} }
else if (strieql(opt, "pass")) { else if (strieql(opt, "pass"))
{
aa.type = GMB_NONE; aa.type = GMB_NONE;
break; 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))
{
gettok(&key, &val);
}
//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); gettok(&key, &val);

View File

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