提高FastReplace速度 (fStrRep.pas)[3]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 luckyjan 的 blog

    mov esi, afindstring
    mov ecx, sourcelen
    mov  al, [esi]

    //add by shengquanhu:just modified the lowercase 'a'..'z'
    cmp al, $7a
    ja @scasb

    cmp al, $61
    jb @scasb
    //end------------------------------------------

    // make al uppercase.
    and  al, $df

    @scasb:
    mov  ah, [edi]

    //add by shengquanhu:just modified the lowercase 'a'..'z'
    cmp ah, $7a
    ja @comparechar

    cmp ah, $61
    jb @comparechar
    //end------------------------------------------

    // make ah uppercase.
    and  ah, $df

    @comparechar:
    cmp  ah,al
    jne  @nextchar
    @comparestrings:
    mov  ebx, afindlen
    dec  ebx

    //add by shengquanhu
    jz   @endofmatch
    //add end

    @comparenext:
    mov  al, [esi+ebx]
    mov  ah, [edi+ebx]

    //add by shengquanhu:just modified the lowercase 'a'..'z'
    cmp ah, $7a
    ja @lowerah

    cmp al, $61
    jb @lowerah
    //end------------------------------------------

    // make al and ah uppercase.
    and  al, $df

    //add by shengquanhu:just modified the lowercase 'a'..'z'
    @lowerah:
    cmp ah, $7a
    ja @comparechar2

    cmp ah, $61
    jb @comparechar2
    //end------------------------------------------

    and  ah, $df

    @comparechar2:
    cmp  al, ah
    jz   @matches
    mov  al, [esi]

    //add by shengquanhu:just modified the lowercase 'a'..'z'
    cmp al, $7a
    ja @nextchar

    cmp al, $61
    jb @nextchar
    //end------------------------------------------

    // make al uppercase.
    and  al, $df
    jmp  @nextchar
    @matches:
    dec  ebx
    jnz  @comparenext

    //add by shengquanhu
    @endofmatch:
    //add end

    mov  eax, edi
    sub  eax, asourcestring
    inc  eax
    mov  result, eax
    jmp  @theend
    @nextchar:
    inc  edi
    dec  ecx
    //add by shengquanhu
    //if ah is chinese char,jump again
    jz   @result0
    cmp  ah, $80
    jb   @scasb
    inc  edi
    dec  ecx
    //add by shengquanhu end
    jnz  @scasb
    @result0:
    mov  result,0
    @theend:
    pop  ebx
    pop  edi
    pop  esi
  end;
end;

//my move isn’t as fast as move when source and destination are both dword al
//igned, but it’s certainly faster when they’re not. as we’re moving charac
//ters in a string, it isn’t very likely at all that both source and destinat

本文关键:提高FastReplace速度 (fStrRep.pas)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top