1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-26 14:38:34 +01:00

improved TokenizedString splitting efficiency

This commit is contained in:
Ell 2021-04-14 02:47:41 +02:00
parent 6e2db418c5
commit 538fd08d8a

View file

@ -68,9 +68,9 @@ namespace MLEM.Formatting {
var length = 0;
var ret = new StringBuilder();
// this is basically a substring function that ignores newlines for indexing
for (var i = 0; i < this.splitString.Length; i++) {
for (var i = 0; i < this.splitString.Length && length < token.Substring.Length; i++) {
// if we're within the bounds of the token's substring, append to the new substring
if (index >= token.Index && length < token.Substring.Length)
if (index >= token.Index)
ret.Append(this.splitString[i]);
// if the current char is not a newline, we simulate length increase
if (this.splitString[i] != '\n') {