if (cur->next->count > entry->count) { cur = cur->next; }
if #if defined(SORT_BY_CALL_COUNT) (cur->next->count > entry->count) #else ((cur->next->hits > entry->hits) || (cur->next->hits == entry->hits && cur->next->count > entry->count)) #endif { cur = cur->next; }
ListCounts(PLDHashTable* table, PLDHashEntryHdr* hdr,           PRUint32 number, void* arg){    BOOL ok;    CallEntry* entry = (CallEntry*) hdr;    IMAGEHLP_MODULE module;    module.SizeOfStruct = sizeof(module);    ok = ::SymGetModuleInfo(::GetCurrentProcess(),                            (unsigned) entry->addr,                            &module);    char buf[sizeof(IMAGEHLP_SYMBOL) + 512];    PIMAGEHLP_SYMBOL symbol = (PIMAGEHLP_SYMBOL) buf;    symbol->SizeOfStruct = sizeof(buf);    symbol->MaxNameLength = 512;    DWORD displacement;    ok = ::SymGetSymFromAddr(::GetCurrentProcess(),                             (unsigned) entry->addr,                             &displacement,                             symbol);    if (ok)    {        if (displacement > 0)             return PL_DHASH_NEXT;        static int modInitialized = 0;        if (! modInitialized) {            modInitialized = 1;            PL_DHashTableInit(&Modules, &ModOps, 0, sizeof(ModulesEntry), 16);        }        ModulesEntry* mod            = (ModulesEntry*) PL_DHashTableOperate(&Modules,                                                    module.ModuleName,                                                    PL_DHASH_LOOKUP);        if (PL_DHASH_ENTRY_IS_FREE(&mod->hdr)) {            mod = (ModulesEntry*) PL_DHashTableOperate(&Modules,                                                       module.ModuleName,                                                       PL_DHASH_ADD);            mod->moduleName = strdup(module.ModuleName);            mod->byCount = new Node();            mod->byCount->function = strdup(symbol->Name);            mod->byCount->count = entry->count;        } else {            // insertion sort.            Node* cur = mod->byCount;            Node* foo = new Node();            foo->function = strdup(symbol->Name);            foo->count = entry->count;            if (cur->count < entry->count) {                if (!strcmp(cur->function,symbol->Name))                     return PL_DHASH_NEXT;                foo->next = mod->byCount;                mod->byCount = foo;                            } else {                while (cur->next) {                    if (!strcmp(cur->function,symbol->Name))                         return PL_DHASH_NEXT;                    if (cur->next->count > entry->count) { cur = cur->next; }                    else { break; }                }                foo->next = cur->next;                  cur->next = foo;            }        }    } // if (ok)    return PL_DHASH_NEXT;}