"Instr" vs "string.find()"? FIGHT!
BlitzMax Forums/BlitzMax Beginners Area/"Instr" vs "string.find()"? FIGHT!
| ||
Hi! Just found out out that you can use string.find() as a kind of replacement for Instr. 1. Has anyone done speed test with that already. Is find() any faster? 2. Is it possible to add a starting position for a search with find too? I really have a lot of Instr() usage in my 8000 lines app. But before I replace Instr(), I'd like to be sure about this. Local s:String="This is a Test string..." Print "Find result: "+s.Find("Test") Print "Instr result: "+Instr(s,"Test") Grisu |
| ||
Yes, the syntax is: Find:Int( subString:String,startIndex=0 ) unlike Instr, Find returns -1 if not found, 0 is the first char. Also there's Findlast: FindLast:Int( subString:String,startIndex=0 ) Don't know about the speed... Jake |
| ||
hi, in fact Instr uses the String intern Method Find() with the only exception, that the result of Instr is zero baased, as Find is -1 based. The Speed is almost the same (in non DebugMode) |
| ||
Thanks guys. Find seems to be faster. Every little speed increase helps, so I think I'll have to recode my stuff. |
| ||
Yeah. Throw away that retro module and move on :-) It would certainly make sense that Find would be slightly faster than Instr, given that Instr is making a call to Find anyways. |