From d93aa77a8cada13c3edf0e06f0f922165b9bed49 Mon Sep 17 00:00:00 2001 From: Jonson <596809147@qq.com> Date: Fri, 16 Dec 2016 11:11:06 +0800 Subject: [PATCH] Fix Format & LastIndexOf BUG --- GC Free String/gstring.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/GC Free String/gstring.cs b/GC Free String/gstring.cs index 800e8d8..8ed4b39 100644 --- a/GC Free String/gstring.cs +++ b/GC Free String/gstring.cs @@ -225,17 +225,12 @@ internal unsafe static gstring internal_format(string input, int num_args) { for(int k = 0; i < new_len; ) { - if (j < brace_idx) - ptr_result[i++] = ptr_input[j++]; - else + if (j >= brace_idx && j <= brace_idx + 2) { ptr_result[i++] = arg[k++]; - if (k == arg.Length) - { - j += 3; - break; - } + if (k == arg.Length) j += 3; } + else ptr_result[i++] = ptr_input[j++]; } } } @@ -899,8 +894,8 @@ public int LastIndexOf(string value) int last_find = -1; while(true) { - idx = internal_index_of(this._value, value, idx + value.Length); - last_find = idx; + idx = internal_index_of(this._value, value, idx + 1); + last_find = idx; if (idx == -1 || idx + value.Length >= this._value.Length) break; } @@ -913,8 +908,8 @@ public int LastIndexOf(char value) int last_find = -1; while(true) { - idx = internal_index_of(this._value, value, idx + 1); - last_find = idx; + idx = internal_index_of(this._value, value, idx + 1); + last_find = idx; if (idx == -1 || idx + 1 >= this._value.Length) break; }