Hi,
my code is slow. I have to rethink of it. Can you help?
I'm displaying a logfile from a license server.
I have a vector (m_lines) of
struct LINE
{
STATUS status; // LOGIN or LOGOUT
int hex; // the "user" id
time_t time; // time of login/out
};
which are sorted by time.
Now for each hex's LOGIN there must be a LOGOUT.
If there is none (no idea why), I'll have to add it.
Here's my code so far:
void ForceLogouts()
{
int num = (int)m_lines.si ze();
for(int i=0; i<num; ++i)
{
LINE& line1 = m_lines[i];
if(line1.status ==ST_LOGIN)
{
for(int j=i+1; j<num; ++j)
{
LINE& line2 = m_lines[i];
// good logout
if(line2.hex == line1.hex && line2.status==S T_LOGOUT)
{
goto skipme;
}
}
// this one needs a logout badly!
LINE lt(line1);
tmday = &line1.time + 10000;
lt.status=ST_LO GOUT;
m_lines.push_ba ck(lt);
}
skipme:;
}
// sort(m_lines, ...); // sort in new entries by time
}
What can I do? Sort the data by 'hex' first?
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%c gl%ssic%ccom%c" , "ma", 58, 'g', 64, "ba", 46, 10);}
Comment