19 Jul, 2007, Omega wrote in the 21st comment:
Votes: 0
already know the ++iter technique ;) been actively using it :)

and, now i'm trying to understand gprof :P got the output, just don't know what todo with it, ie, how to interpret it so I can figure out what needs to be optimized and what-not :P

but anywho..

gosub.. bad conner! BAD!.. :P

And you, davion, out of the gene pool… Using goto's….. Sheesh… What do you think this is… VB :P

I don't touch those unless i'm using microsoft tools to code with, because at that point in time, I don't care what happens. But this is for sstm, so its serious ;)
19 Jul, 2007, Dorian wrote in the 22nd comment:
Votes: 0
Justice said:
Scandum said:
Justice said:
For iteration, it isn't any faster.

Wrong, an array is much faster when it comes to iteration.

Obviously you haven't tested them. At best you get equivalent results, however the array degrades rapidly for multiple access if you don't set a pointer to the element. This is because the array calculates a memory position using the index and the sizeof each element.


True, but arrays are usually faster on modern machines. It's usually easier for a block of array elements to stay in a CPU's cache than a linked list.
19 Jul, 2007, Scandum wrote in the 23rd comment:
Votes: 0
Which is also why setting a pointer would be pointless, pun intended.

I figured to compare the initialization times as well:

scandum's init time:   19557, justice's init time:   259814
scandum's exec time: 16945, justice's exec time: 51367


0.020 vs 0.260 seconds is a pretty massive difference.
19 Jul, 2007, Omega wrote in the 24th comment:
Votes: 0
okay, so since arrays are evil, and iteration is equally bad (using all the logic spouted off here) Then what about std::maps.

as they are just a glorified array that you iterate-through, which reads faster then a standard array, and only uses the memory blocks that are indeed, set.

case and point.

old learned.
int learned[MAX_SKILL];

New
std::map<int,int>learned;

instead of doing a for-loop to process through ch->learned till it hits HAX_SKILL or what-not.
it instead uses an iterator to parse through the set-data within the map. Cutting out the middle-man all together,
carefully avoiding things that have not been set.

so… since a map is just an array with iterators…….. isn't an array, that iterates, better?
19 Jul, 2007, Scandum wrote in the 25th comment:
Votes: 0
I'm not sure what you mean Darien, there's a fine line between genius and insanity though.

for (area = mud->f_area ; area ; area = area->next)
{
for (vnum = area->low_m_vnum ; vnum <= area->hi_m_vnum ; vnum++)
{
if (mob_index[vnum] == NULL || mob_index[vnum]->first_instance == NULL)
{
continue;
}

if (IS_SET(mob_index[vnum]->progtypes, RAND_PROG))
{
for (ich = mob_index[vnum]->first_instance ; ich ; ich = mud->update_ich)
{
mud->update_ich = ich->next_instance;
19 Jul, 2007, Omega wrote in the 26th comment:
Votes: 0
you can iterate through a std::map

http://www.mudbytes.net/index.php?a=topi...

see previous topic on std::map

most notibly, this.

for(SkillsMap::iterator skill_iter = ch->pcdata->learned.begin(); skill_iter != ch->pcdata->learned.end(); ++skill_iter)
{
if(skill_iter->second <= 0)
continue;

return skill_iter->second;
}

easily sorted through, saves time, big-time :)
20.0/26