In TStringBuilder there is a function bmx_stringbuilder_matches that is not exposed in common.bmx. This function is currently used internally for startsWith() but can be used to extend this function so we can perform quicker substring checks.
The code below extends TStringBuilder with a new startsWith() that allows you to begin the search at any point within the buffer; but the method could easily be added into TStringBuilder.
SuperStrict
Extern
Function bmx_stringbuilder_matches:Int(buffer:Byte Ptr, beginIndex:Int, subString:String)
End Extern
Type TStringBuilderPlus Extends TStringBuilder
Rem
bbdoc: Returns true if string starts with @subString.
End Rem
Method StartsWith:Int( subString:String, start:Int )
Return bmx_stringbuilder_matches( buffer, start, subString )
End Method
End Type
Local sb:TStringBuilderPlus = New TStringBuilderPlus()
sb.append( "Hello World, what a great day" )
If sb.startswith( "World", 6 ); Print "YES"
In TStringBuilder there is a function
bmx_stringbuilder_matches
that is not exposed in common.bmx. This function is currently used internally forstartsWith()
but can be used to extend this function so we can perform quicker substring checks.The code below extends TStringBuilder with a new startsWith() that allows you to begin the search at any point within the buffer; but the method could easily be added into TStringBuilder.
Please could you consider this to be included?
Regards, Si... [Scaremonger]