using System; using System.Collections; namespace System.Text.RegularExpressions { // Token: 0x020002D6 RID: 726 internal class QuickSearch { // Token: 0x06001A83 RID: 6787 RVA: 0x00061A00 File Offset: 0x0005FC00 public QuickSearch(string str, bool ignore) : this(str, ignore, false) { } // Token: 0x06001A84 RID: 6788 RVA: 0x00061A0C File Offset: 0x0005FC0C public QuickSearch(string str, bool ignore, bool reverse) { this.str = str; this.len = str.Length; this.ignore = ignore; this.reverse = reverse; if (ignore) { str = str.ToLower(); } if (this.len > QuickSearch.THRESHOLD) { this.SetupShiftTable(); } } // Token: 0x17000820 RID: 2080 // (get) Token: 0x06001A86 RID: 6790 RVA: 0x00061A6C File Offset: 0x0005FC6C public string String { get { return this.str; } } // Token: 0x17000821 RID: 2081 // (get) Token: 0x06001A87 RID: 6791 RVA: 0x00061A74 File Offset: 0x0005FC74 public int Length { get { return this.len; } } // Token: 0x17000822 RID: 2082 // (get) Token: 0x06001A88 RID: 6792 RVA: 0x00061A7C File Offset: 0x0005FC7C public bool IgnoreCase { get { return this.ignore; } } // Token: 0x06001A89 RID: 6793 RVA: 0x00061A84 File Offset: 0x0005FC84 public int Search(string text, int start, int end) { int i = start; if (this.reverse) { if (start < end) { return -1; } if (i > text.Length) { i = text.Length; } if (this.len == 1) { while (--i >= end) { if (this.str[0] == this.GetChar(text[i])) { return i; } } return -1; } if (end < this.len) { end = this.len - 1; } for (i--; i >= end; i -= this.GetShiftDistance(text[i - this.len])) { int num = this.len - 1; while (this.str[num] == this.GetChar(text[i - this.len + 1 + num])) { if (--num < 0) { return i - this.len + 1; } } if (i <= end) { break; } } } else { if (this.len == 1) { while (i <= end) { if (this.str[0] == this.GetChar(text[i])) { return i; } i++; } return -1; } if (end > text.Length - this.len) { end = text.Length - this.len; } while (i <= end) { int num2 = this.len - 1; while (this.str[num2] == this.GetChar(text[i + num2])) { if (--num2 < 0) { return i; } } if (i >= end) { break; } i += this.GetShiftDistance(text[i + this.len]); } } return -1; } // Token: 0x06001A8A RID: 6794 RVA: 0x00061C68 File Offset: 0x0005FE68 private void SetupShiftTable() { bool flag = this.len > 254; byte b = 0; for (int i = 0; i < this.len; i++) { char c = this.str[i]; if (c <= 'ÿ') { if ((byte)c > b) { b = (byte)c; } } else { flag = true; } } this.shift = new byte[(int)(b + 1)]; if (flag) { this.shiftExtended = new Hashtable(); } int j = 0; int num = this.len; while (j < this.len) { char c2 = this.str[this.reverse ? (num - 1) : j]; if ((int)c2 >= this.shift.Length) { goto IL_DD; } if (num >= 255) { this.shift[(int)c2] = byte.MaxValue; goto IL_DD; } this.shift[(int)c2] = (byte)num; IL_F6: j++; num--; continue; IL_DD: this.shiftExtended[c2] = num; goto IL_F6; } } // Token: 0x06001A8B RID: 6795 RVA: 0x00061D84 File Offset: 0x0005FF84 private int GetShiftDistance(char c) { if (this.shift == null) { return 1; } c = this.GetChar(c); if ((int)c < this.shift.Length) { int num = (int)this.shift[(int)c]; if (num == 0) { return this.len + 1; } if (num != 255) { return num; } } else if (c < 'ÿ') { return this.len + 1; } if (this.shiftExtended == null) { return this.len + 1; } object obj = this.shiftExtended[c]; return (obj == null) ? (this.len + 1) : ((int)obj); } // Token: 0x06001A8C RID: 6796 RVA: 0x00061E34 File Offset: 0x00060034 private char GetChar(char c) { return this.ignore ? char.ToLower(c) : c; } // Token: 0x040015A5 RID: 5541 private string str; // Token: 0x040015A6 RID: 5542 private int len; // Token: 0x040015A7 RID: 5543 private bool ignore; // Token: 0x040015A8 RID: 5544 private bool reverse; // Token: 0x040015A9 RID: 5545 private byte[] shift; // Token: 0x040015AA RID: 5546 private Hashtable shiftExtended; // Token: 0x040015AB RID: 5547 private static readonly int THRESHOLD = 5; } }