"dev42" wrote:
What sort of memory overhead is there for using this just for .split vs. rolling our own?
Little at all, just the memory of the routine. Using .split would take none since the library is already on the device, and using a custom routine line the following just creates a new array so little at is used - the code size of the routine would be negligible. Since mine is used in a deserialization routine called thousands of times, I create the result array one time, and clear and reuse it every pass, avoids lots of allocations and GC.
The code below could easily be adjusted to split on strings by adjusting the offsets in the Value.Mid calls.
function roStringSplit(Result, Value, Delimiter) as object ' Is like tokenize but doesnt dump empty values, boxed version
Result.Clear()
OldSpot=-1: Spot = Value.Instr(Delimiter)
while Spot<>-1
Result.Push(Value.Mid(OldSpot+1,Spot-OldSpot-1))
OldSpot=Spot
Spot = Value.Instr(Spot+1, Delimiter)
end while
Result.Push(Value.Mid(OldSpot+1))
return Result
end function
But, even with me doing what I can to move as little data as possible in this routine (reusing array, no array of delim locations, no string copy) it's performance is not noticeably better than .split.