- Fixed a bug with the split() proc.
- Changed how the replace proc works to increase its speed by 50%.
- Added the Replace() and split() procs which are case-sensitive versions of replace and split.
- Added the prefix() and ending() procs which determine if one string starts or ends with another string. Prefix() and Ending() are the case-sensitive versions.
- Did some benchmarking to compare performance against the Deadron.TextHandling library. The benchmarking code is included as demo\benchmark.dm
Forum_account.Text 50,000 calls in 5.700 seconds: 114 microseconds per call
Deadron.TextHandling 50,000 calls in 9.520 seconds: 190 microseconds per call
Forum_account.Text 50,000 calls in 3.150 seconds: 63 microseconds per call
Deadron.TextHandling 50,000 calls in 4.176 seconds: 83 microseconds per call
Forum_account.Text 50,000 calls in 1.894 seconds: 38 microseconds per call
Deadron.TextHandling 50,000 calls in 5.537 seconds: 110 microseconds per call
The prefix() and ending() procs are almost identical to the dd_hasprefix and dd_hassuffix procs. Their performance is about the same and because those procs are so simple, it can't make much of a difference. The only difference is because the dd_hassuffix proc is incorrect:
var/start = length(text) - length(suffix)
if (start) return findtext(text, suffix, start)
it should be findtext(text, suffix, start + 1), otherwise this will happen:
world << "oops!"
The value of start will be length("fails") - length("fail"), which is 1. String indexes start at 1, so this is checking if the string "fail" is found in "fails" (and it is). Instead it should start checking at index = 2, so it checks if "fail" is found in "ails" (and it's not). The library even has an automatic built-in test, oops indeed!