View Single Post
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-16-2009 , 22:55   Re: [INC] CellTravTrie
Reply With Quote #2

Why do you have checks to see if the strings begin with the newline character? Won't you meant the null character?

Other thing: there is a recurrent "problem" in her coding (it also happens in ArrayX):

This:

PHP Code:
stock bool:TravTrieSetCell(TravTrie:trie, const key[], any:value)
{
    if(
key[0] == '^n') return false;
    
    new 
any:val;
    if(!
TravTrieGetCell(triekeyval) )
    {
        new Array:
iter;
        if(!
TrieGetCell(Trie:trie,"",any:iter)) return false;
    
        
ArrayPushString(Array:iter,key);
    }
    if(
key[0] == '^n') return false;
    
    
TrieSetCell(Trie:trie,key,value);
    return 
true;

should be:

PHP Code:
stock bool:TravTrieSetCell(TravTrie:trie, const key[], any:value)
{
    if(
key[0] == '^n') return false;
    
    new 
any:val;
    if(!
TravTrieGetCell(triekeyval) )
    {
        new Array:
iter;
        if(!
TrieGetCell(Trie:trie,"",any:iter)) return false;
    
        
ArrayPushString(Array:iter,key);

        if(
key[0] == '^n') return false;
    }
    
    
TrieSetCell(Trie:trie,key,value);
    return 
true;

In keytable_natives.cpp she has
PHP Code:
if(== endhandle->lower_bound(start);
if(
== endhandle->upper_bound(start);
if(
== end) return 0;
else 
len--; 
It should be:

PHP Code:
if(== end
{
    
handle->lower_bound(start)
        
    if(
== end)
        
handle->upper_bound(start);
}

if(
== end)
    return 
0
else
    
len-- 
Not that it matter that much to performance but i thought that she has extremely rigorous at coding. It seems that she prefers to compact the code instead of making it more accurate
__________________

Last edited by joaquimandrade; 03-16-2009 at 23:32.
joaquimandrade is offline