[Off] strcmp veloz
#7

Quote:
Originally Posted by ipsBruno
Посмотреть сообщение
Consegui, um em mйdia 30 vezes mais veloz:

pawn Код:
fstrcmp(str[], str2[], bool: cases = true){

    static __len, _len;
   
    __len = strlen(str);
    _len = strlen(str2);
   
    if(__len != _len) if(__len > _len) return -1; else return 1;

    switch(cases){
        case 0: {
            for( ; --__len > -1 ; ) {
                if(!(str[__len] - str2[__len])) return -2;
            }
        }
        default: {
            for( ; --__len > -1 ; ) {
                if(!(tolower(str[__len]) - tolower(str2[__len]))) return -2;
            }
        }
    }
    return 0;
}
Por enquanto estб comparando certo. Resta saber se os testes estгo dizendo a verdade
Seu sem graзa


eu adicionando um simples loop jб fica fica 500% mais lento que o nativa!

pawn Код:
istrcmp(str[], str2[], bool: per = true){

    static
        a,
        n
    ;
   
    a = strlen(str);
    n = strlen(str2);
   
    if(a > n) return -1;
    if(a < n) return 1;

    for(new i; str[i]; ++i) if(tolower(str[i]) != tolower(str2[i])) return 1;
    return 0;
}
#EDIT:

seus testes:
Reply


Messages In This Thread
strcmp veloz - by ipsBruno - 30.09.2013, 05:26
Re: strcmp veloz - by zSuYaNw - 30.09.2013, 05:45
Re: strcmp veloz - by ipsBruno - 30.09.2013, 05:46
Re: strcmp veloz - by zSuYaNw - 30.09.2013, 05:50
Re: strcmp veloz - by ipsBruno - 30.09.2013, 05:54
Re: strcmp veloz - by ipsBruno - 30.09.2013, 06:15
Re: strcmp veloz - by zSuYaNw - 30.09.2013, 06:19
Re: strcmp veloz - by ipsBruno - 30.09.2013, 06:21
Re: strcmp veloz - by zSuYaNw - 30.09.2013, 06:22
Re: strcmp veloz - by ipsBruno - 30.09.2013, 06:25

Forum Jump:


Users browsing this thread: 3 Guest(s)