Jump to content

Recommended Posts

Posted

There is a list of hashes of several thousand. I need to see if the first character is not the same, then go through the 40 characters. StringInStr checks all 40 characters, while the width is the width of the search template, and it makes no sense to check start with all characters.

$vData = FileRead(@ScriptDir&'\SHA.txt')
$sSHA = 'E18979B1542A4F499DD618CD52723D220507A268'
$timer = TimerInit()
$s = _Alike_Lines($vData, $sSHA)
$timer = TimerDiff($timer)
MsgBox(0, $s, 'Время : ' & Round($timer, 2) & ' мсек')

Func _Alike_Lines($vData, $sSHA)
    $iStart = 1
    For $i = 1 To Int(StringLen($vData) / 40)
        If StringInStr($vData, $sSHA, 2, 1, $iStart, 40) Then Return 1
        $iStart += 40
    Next
EndFunc
Posted

This is faster than StringInStr()

Func Search($vData, $sSHA)
    Return StringRegExp($vData, $sSHA, 0)
EndFunc

Do you want a StringInStr() solution or you just search for the fastest function?

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

There is a remark: The count parameter must be longer than the substring being searched for. but it's still not faster.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

correctly

afgsdsdfsd sdfdgdfgdfg

123456789 Step 1

123456789 Step 2

badly

afgsdsdfsd sdfdgdfgdfg

123456789 Step 1

123456789 Step 2

123456789 Step 3

it isn't checked that the required line goes beyond and to look for there is no sense.

Edited by AZJIO
Posted (edited)

sorry, can't dl the file, but in your above sample, there are spaces, which need to be accounted for

$vWontFindData = 'E18979B1542A4F499DD618CD52723D220507A26b E18979B1542A4F499DD618CD52723D220507A26b E18979B1542A4F499DD618CD52723D220507A26c E18979B1542A4F499DD618CD52723D220507A26d'

;                                                                                                  Match
$vWillFindData = 'E18979B1542A4F499DD618CD52723D220507A26a E18979B1542A4F499DD618CD52723D220507A26b E18979B1542A4F499DD618CD52723D220507A268 E18979B1542A4F499DD618CD52723D220507A26c'
;~ $vData = StringRegExpReplace ($vData, "\s", "")
$sSHA = 'E18979B1542A4F499DD618CD52723D220507A268'
$timer = TimerInit()
$s = _Alike_Lines($vWillFindData, $sSHA)
$timer = TimerDiff($timer)
MsgBox(0, $s, '????? : ' & Round($timer, 2) & ' ????')
$timer = TimerInit()
$s = _Alike_Lines($vWontFindData, $sSHA)
$timer = TimerDiff($timer)
MsgBox(0, $s, '????? : ' & Round($timer, 2) & ' ????')
Func _Alike_Lines($vData, $sSHA)
    $iStart = 1
 $iJump = StringLen($sSHA)+1
    For $i = 1 To Int(StringLen($vData) / $iJump)
        If StringInStr($vData, $sSHA, 2, 1, $iStart, $iJump-1) Then Return 1
        $iStart += $iJump
    Next
EndFunc

Would you mind cutting and pasting some of the file?

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...