AZJIO Posted March 6, 2013 Share Posted March 6, 2013 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 My other projects or all Link to comment Share on other sites More sharing options...
jdelaney Posted March 6, 2013 Share Posted March 6, 2013 (edited) are there any line feeds or carriage retruns or white space? Those count as chars $vData = StringRegExpReplace ($vData, "\s", "") Edited March 6, 2013 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. Link to comment Share on other sites More sharing options...
UEZ Posted March 6, 2013 Share Posted March 6, 2013 Do you have a SHA.txt file where we can test? 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
AZJIO Posted March 6, 2013 Author Share Posted March 6, 2013 (edited) http://my-soft-autoit.googlecode.com/files/SHA.7zIf I removed ", 40" time of test didn't changeIf StringInStr($vData, $sSHA, 2, 1, $iStart, 40) Then Return 1 Edited March 6, 2013 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
UEZ Posted March 6, 2013 Share Posted March 6, 2013 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
AZJIO Posted March 6, 2013 Author Share Posted March 6, 2013 I expected that the function StringInStr be 40 times faster, by offset My other projects or all Link to comment Share on other sites More sharing options...
UEZ Posted March 6, 2013 Share Posted March 6, 2013 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
AZJIO Posted March 6, 2013 Author Share Posted March 6, 2013 (edited) correctlyafgsdsdfsd sdfdgdfgdfg123456789 Step 1 123456789 Step 2badlyafgsdsdfsd sdfdgdfgdfg123456789 Step 1 123456789 Step 2 123456789 Step 3it isn't checked that the required line goes beyond and to look for there is no sense. Edited March 6, 2013 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
jdelaney Posted March 6, 2013 Share Posted March 6, 2013 (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 March 6, 2013 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now