-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastStrList.pas
More file actions
713 lines (657 loc) · 18.7 KB
/
FastStrList.pas
File metadata and controls
713 lines (657 loc) · 18.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
unit FastStrList;
interface
uses Windows, KOL;
type
PFastStrListEx = ^TFastStrListEx;
TFastStrListEx = object(TObj)
private
function GetItemLen(Idx: Integer): Integer;
function GetObject(Idx: Integer): DWORD;
procedure SetObject(Idx: Integer; const Value: DWORD);
function GetValues(AName: PAnsiChar): PAnsiChar;
protected
procedure Init; virtual;
protected
fList: PList;
fCount: Integer;
fCaseSensitiveSort: Boolean;
fTextBuf: PAnsiChar;
fTextSiz: DWORD;
fUsedSiz: DWORD;
protected
procedure ProvideSpace(AddSize: DWORD);
function Get(Idx: Integer): ansistring;
function GetTextStr: ansistring;
procedure Put(Idx: Integer; const Value: ansistring);
procedure SetTextStr(const Value: ansistring);
function GetPAnsiChars(Idx: Integer): PAnsiChar;
{ ++ }(* public *){ -- }
destructor Destroy; { - } virtual; { + }{ ++ }(* override; *){ -- }
public
function AddAnsi(const S: AnsiString): Integer;
{ * Adds Ansi AnsiString to a list. }
function AddAnsiObject(const S: AnsiString; Obj: DWORD): Integer;
{ * Adds Ansi AnsiString and correspondent object to a list. }
function Add(S: PAnsiChar): Integer;
{ * Adds a string to list. }
function AddLen(S: PAnsiChar; Len: Integer): Integer;
{ * Adds a string to list. The string can contain #0 characters. }
procedure Clear;
{ * Makes string list empty. }
procedure Delete(Idx: Integer);
{ * Deletes string with given index (it *must* exist). }
function IndexOf(const S: ansistring): Integer;
{ * Returns index of first string, equal to given one. }
function IndexOf_NoCase(const S: ansistring): Integer;
{ * Returns index of first string, equal to given one (while comparing it
without case sensitivity). }
function IndexOfStrL_NoCase(Str: PAnsiChar; L: Integer): Integer;
{ * Returns index of first string, equal to given one (while comparing it
without case sensitivity). }
function Find(const S: AnsiString; var Index: Integer): Boolean;
{ * Returns Index of the first string, equal or greater to given pattern, but
works only for sorted TFastStrListEx object. Returns TRUE if exact string found,
otherwise nearest (greater then a pattern) string index is returned,
and the result is FALSE. }
procedure InsertAnsi(Idx: Integer; const S: AnsiString);
{ * Inserts ANSI string before one with given index. }
procedure InsertAnsiObject(Idx: Integer; const S: AnsiString; Obj: DWORD);
{ * Inserts ANSI string before one with given index. }
procedure Insert(Idx: Integer; S: PAnsiChar);
{ * Inserts string before one with given index. }
procedure InsertLen(Idx: Integer; S: PAnsiChar; Len: Integer);
{ * Inserts string from given PAnsiChar. It can contain #0 characters. }
function LoadFromFile(const FileName: ansistring): Boolean;
{ * Loads string list from a file. (If file does not exist, nothing
happens). Very fast even for huge text files. }
procedure LoadFromStream(Stream: PStream; Append2List: Boolean);
{ * Loads string list from a stream (from current position to the end of
a stream). Very fast even for huge text. }
procedure MergeFromFile(const FileName: ansistring);
{ * Merges string list with strings in a file. Fast. }
procedure Move(CurIndex, NewIndex: Integer);
{ * Moves string to another location. }
procedure SetText(const S: ansistring; Append2List: Boolean);
{ * Allows to set strings of string list from given string (in which
strings are separated by $0D,$0A or $0D characters). Text can
contain #0 characters. Works very fast. This method is used in
all others, working with text arrays (LoadFromFile, MergeFromFile,
Assign, AddAnsiStrings). }
function SaveToFile(const FileName: ansistring): Boolean;
{ * Stores string list to a file. }
procedure SaveToStream(Stream: PStream);
{ * Saves string list to a stream (from current position). }
function AppendToFile(const FileName: ansistring): Boolean;
{ * Appends strings of string list to the end of a file. }
property Count: Integer read fCount;
{ * Number of strings in a string list. }
property Items[Idx: Integer]: ansistring read Get write Put; default;
{ * AnsiStrings array items. If item does not exist, empty string is returned.
But for assign to property, string with given index *must* exist. }
property ItemPtrs[Idx: Integer]: PAnsiChar read GetPAnsiChars;
{ * Fast access to item strings as PAnsiChars. }
property ItemLen[Idx: Integer]: Integer read GetItemLen;
{ * Length of string item. }
function Last: AnsiString;
{ * Last item (or '', if string list is empty). }
property Text: ansistring read GetTextStr write SetTextStr;
{ * Content of string list as a single string (where strings are separated
by characters $0D,$0A). }
procedure Swap(Idx1, Idx2: Integer);
{ * Swaps to strings with given indeces. }
procedure Sort(CaseSensitive: Boolean);
{ * Call it to sort string list. }
public
function AddObject(S: PAnsiChar; Obj: DWORD): Integer;
function AddObjectLen(S: PAnsiChar; Len: Integer; Obj: DWORD): Integer;
procedure InsertObject(Idx: Integer; S: PAnsiChar; Obj: DWORD);
procedure InsertObjectLen(Idx: Integer; S: PAnsiChar; Len: Integer; Obj: DWORD);
property Objects[Idx: Integer]: DWORD read GetObject write SetObject;
public
property Values[Name: PAnsiChar]: PAnsiChar read GetValues;
function IndexOfName(AName: PAnsiChar): Integer;
end;
function NewFastStrListEx: PFastStrListEx;
var
Upper: array [AnsiChar] of AnsiChar;
Upper_Initialized: Boolean;
procedure InitUpper;
implementation
function NewFastStrListEx: PFastStrListEx;
begin
new(Result, Create);
end;
procedure InitUpper;
var
c: AnsiChar;
begin
for c := #0 to #255 do
Upper[c] := AnsiUpperCase(c + #0)[1];
Upper_Initialized := TRUE;
end;
{ TFastStrListEx }
function TFastStrListEx.AddAnsi(const S: AnsiString): Integer;
begin
Result := AddObjectLen(PAnsiChar(S), Length(S), 0);
end;
function TFastStrListEx.AddAnsiObject(const S: AnsiString; Obj: DWORD): Integer;
begin
Result := AddObjectLen(PAnsiChar(S), Length(S), Obj);
end;
function TFastStrListEx.Add(S: PAnsiChar): Integer;
begin
Result := AddObjectLen(S, StrLen(S), 0)
end;
function TFastStrListEx.AddLen(S: PAnsiChar; Len: Integer): Integer;
begin
Result := AddObjectLen(S, Len, 0)
end;
function TFastStrListEx.AddObject(S: PAnsiChar; Obj: DWORD): Integer;
begin
Result := AddObjectLen(S, StrLen(S), Obj)
end;
function TFastStrListEx.AddObjectLen(S: PAnsiChar; Len: Integer;
Obj: DWORD): Integer;
var
Dest: PAnsiChar;
begin
ProvideSpace(Len + 9);
Dest := PAnsiChar(DWORD(fTextBuf) + fUsedSiz);
Result := fCount;
Inc(fCount);
fList.Add(Pointer(DWORD(Dest) - DWORD(fTextBuf)));
PDWORD(Dest)^ := Obj;
Inc(Dest, 4);
PDWORD(Dest)^ := Len;
Inc(Dest, 4);
if S <> nil then
System.Move(S^, Dest^, Len);
Inc(Dest, Len);
Dest^ := #0;
Inc(fUsedSiz, Len + 9);
end;
function TFastStrListEx.AppendToFile(const FileName: ansistring): Boolean;
var
F: HFile;
Txt: AnsiString;
begin
Txt := Text;
F := FileCreate(FileName, ofOpenAlways or ofOpenReadWrite or
ofShareDenyWrite);
if F = INVALID_HANDLE_VALUE then
Result := FALSE
else
begin
FileSeek(F, 0, spEnd);
Result := FileWrite(F, PAnsiChar(Txt)^, Length(Txt)) = DWORD(Length(Txt));
FileClose(F);
end;
end;
procedure TFastStrListEx.Clear;
begin
fList.Clear;
if fTextBuf <> nil then
FreeMem(fTextBuf);
fTextBuf := nil;
fTextSiz := 0;
fUsedSiz := 0;
fCount := 0;
end;
procedure TFastStrListEx.Delete(Idx: Integer);
begin
if (Idx < 0) or (Idx >= Count) then
Exit;
if Idx = Count - 1 then
Dec(fUsedSiz, ItemLen[Idx] + 9);
fList.Delete(Idx);
Dec(fCount);
end;
destructor TFastStrListEx.Destroy;
begin
Clear;
fList.Free;
inherited;
end;
function TFastStrListEx.Find(const S: AnsiString; var Index: Integer): Boolean;
var
i: Integer;
begin
for i := 0 to Count - 1 do
if (ItemLen[i] = Length(S)) and
((S = '') or CompareMem(ItemPtrs[i], @S[1], Length(S))) then
begin
Index := i;
Result := TRUE;
Exit;
end;
Result := FALSE;
end;
function TFastStrListEx.Get(Idx: Integer): ansistring;
begin
if (Idx >= 0) and (Idx <= Count) then
SetString(Result, PAnsiChar(DWORD(fTextBuf) + DWORD(fList.Items[Idx]) + 8), ItemLen[Idx])
else
Result := '';
end;
function TFastStrListEx.GetItemLen(Idx: Integer): Integer;
var
Src: PDWORD;
begin
if (Idx >= 0) and (Idx <= Count) then
begin
Src := PDWORD(DWORD(fTextBuf) + DWORD(fList.Items[Idx]) + 4);
Result := Src^
end
else
Result := 0;
end;
function TFastStrListEx.GetObject(Idx: Integer): DWORD;
var
Src: PDWORD;
begin
if (Idx >= 0) and (Idx <= Count) then
begin
Src := PDWORD(DWORD(fTextBuf) + DWORD(fList.Items[Idx]));
Result := Src^
end
else
Result := 0;
end;
function TFastStrListEx.GetPAnsiChars(Idx: Integer): PAnsiChar;
begin
if (Idx >= 0) and (Idx <= Count) then
Result := PAnsiChar(DWORD(fTextBuf) + DWORD(fList.Items[Idx]) + 8)
else
Result := nil;
end;
function TFastStrListEx.GetTextStr: ansistring;
var
L, i: Integer;
p: PAnsiChar;
begin
L := 0;
for i := 0 to Count - 1 do
Inc(L, ItemLen[i] + 2);
SetLength(Result, L);
p := PAnsiChar(Result);
for i := 0 to Count - 1 do
begin
L := ItemLen[i];
if L > 0 then
begin
System.Move(ItemPtrs[i]^, p^, L);
Inc(p, L);
end;
p^ := #13;
Inc(p);
p^ := #10;
Inc(p);
end;
end;
function TFastStrListEx.IndexOf(const S: ansistring): Integer;
begin
if not Find(S, Result) then
Result := -1;
end;
function TFastStrListEx.IndexOf_NoCase(const S: ansistring): Integer;
begin
Result := IndexOfStrL_NoCase(PAnsiChar(S), Length(S));
end;
function TFastStrListEx.IndexOfStrL_NoCase(Str: PAnsiChar; L: Integer): Integer;
var
i: Integer;
begin
for i := 0 to Count - 1 do
if (ItemLen[i] = L) and
((L = 0) or (StrLComp_NoCase(ItemPtrs[i], Str, L) = 0)) then
begin
Result := i;
Exit;
end;
Result := -1;
end;
procedure TFastStrListEx.Init;
begin
fList := NewList;
end;
procedure TFastStrListEx.InsertAnsi(Idx: Integer; const S: AnsiString);
begin
InsertObjectLen(Idx, PAnsiChar(S), Length(S), 0);
end;
procedure TFastStrListEx.InsertAnsiObject(Idx: Integer; const S: AnsiString;
Obj: DWORD);
begin
InsertObjectLen(Idx, PAnsiChar(S), Length(S), Obj);
end;
procedure TFastStrListEx.Insert(Idx: Integer; S: PAnsiChar);
begin
InsertObjectLen(Idx, S, StrLen(S), 0)
end;
procedure TFastStrListEx.InsertLen(Idx: Integer; S: PAnsiChar; Len: Integer);
begin
InsertObjectLen(Idx, S, Len, 0)
end;
procedure TFastStrListEx.InsertObject(Idx: Integer; S: PAnsiChar; Obj: DWORD);
begin
InsertObjectLen(Idx, S, StrLen(S), Obj);
end;
procedure TFastStrListEx.InsertObjectLen(Idx: Integer; S: PAnsiChar; Len: Integer;
Obj: DWORD);
var
Dest: PAnsiChar;
begin
ProvideSpace(Len + 9);
Dest := PAnsiChar(DWORD(fTextBuf) + fUsedSiz);
fList.Insert(Idx, Pointer(DWORD(Dest) - DWORD(fTextBuf)));
PDWORD(Dest)^ := Obj;
Inc(Dest, 4);
PDWORD(Dest)^ := Len;
Inc(Dest, 4);
if S <> nil then
System.Move(S^, Dest^, Len);
Inc(Dest, Len);
Dest^ := #0;
Inc(fUsedSiz, Len + 9);
Inc(fCount);
end;
function TFastStrListEx.Last: AnsiString;
begin
if Count > 0 then
Result := Items[Count - 1]
else
Result := '';
end;
function TFastStrListEx.LoadFromFile(const FileName: ansistring): Boolean;
var
Strm: PStream;
begin
Strm := NewReadFileStream(FileName);
TRY
Result := Strm.Handle <> INVALID_HANDLE_VALUE;
if Result then
LoadFromStream(Strm, FALSE)
else
Clear;
FINALLY
Strm.Free;
END;
end;
procedure TFastStrListEx.LoadFromStream(Stream: PStream; Append2List: Boolean);
var
Txt: AnsiString;
begin
SetLength(Txt, Stream.Size - Stream.Position);
Stream.Read(Txt[1], Stream.Size - Stream.Position);
SetText(Txt, Append2List);
end;
procedure TFastStrListEx.MergeFromFile(const FileName: ansistring);
var
Strm: PStream;
begin
Strm := NewReadFileStream(FileName);
TRY
LoadFromStream(Strm, TRUE);
FINALLY
Strm.Free;
END;
end;
procedure TFastStrListEx.Move(CurIndex, NewIndex: Integer);
begin
Assert((CurIndex >= 0) and (CurIndex < Count) and (NewIndex >= 0) and
(NewIndex < Count), 'Item indexes violates TFastStrListEx range');
fList.MoveItem(CurIndex, NewIndex);
end;
procedure TFastStrListEx.ProvideSpace(AddSize: DWORD);
var
OldTextBuf: PAnsiChar;
begin
Inc(AddSize, 9);
if AddSize > fTextSiz - fUsedSiz then
begin // óâåëè÷åíèå ðàçìåð?áóôåðà
fTextSiz := Max(1024, (fUsedSiz + AddSize) * 2);
OldTextBuf := fTextBuf;
GetMem(fTextBuf, fTextSiz);
if OldTextBuf <> nil then
begin
System.Move(OldTextBuf^, fTextBuf^, fUsedSiz);
FreeMem(OldTextBuf);
end;
end;
if fList.Count >= fList.Capacity then
fList.Capacity := Max(100, fList.Count * 2);
end;
procedure TFastStrListEx.Put(Idx: Integer; const Value: ansistring);
var
Dest: PAnsiChar;
OldLen: Integer;
OldObj: DWORD;
begin
OldLen := ItemLen[Idx];
if Length(Value) <= OldLen then
begin
Dest := PAnsiChar(DWORD(fTextBuf) + DWORD(fList.Items[Idx]) + 4);
PDWORD(Dest)^ := Length(Value);
Inc(Dest, 4);
if Value <> '' then
System.Move(Value[1], Dest^, Length(Value));
Inc(Dest, Length(Value));
Dest^ := #0;
if Idx = Count - 1 then
Dec(fUsedSiz, OldLen - Length(Value));
end
else
begin
OldObj := 0;
while Idx > Count do
AddObjectLen(nil, 0, 0);
if Idx = Count - 1 then
begin
OldObj := Objects[Idx];
Delete(Idx);
end;
if Idx = Count then
AddObjectLen(PAnsiChar(Value), Length(Value), OldObj)
else
begin
ProvideSpace(Length(Value) + 9);
Dest := PAnsiChar(DWORD(fTextBuf) + fUsedSiz);
fList.Items[Idx] := Pointer(DWORD(Dest) - DWORD(fTextBuf));
Inc(Dest, 4);
PDWORD(Dest)^ := Length(Value);
Inc(Dest, 4);
if Value <> '' then
System.Move(Value[1], Dest^, Length(Value));
Inc(Dest, Length(Value));
Dest^ := #0;
Inc(fUsedSiz, Length(Value) + 9);
end;
end;
end;
function TFastStrListEx.SaveToFile(const FileName: ansistring): Boolean;
var
Strm: PStream;
begin
Strm := NewWriteFileStream(FileName);
TRY
if Strm.Handle <> INVALID_HANDLE_VALUE then
SaveToStream(Strm);
Result := TRUE;
FINALLY
Strm.Free;
END;
end;
procedure TFastStrListEx.SaveToStream(Stream: PStream);
var
Txt: AnsiString;
begin
Txt := Text;
Stream.Write(PAnsiChar(Txt)^, Length(Txt));
end;
procedure TFastStrListEx.SetObject(Idx: Integer; const Value: DWORD);
var
Dest: PDWORD;
begin
if Idx < 0 then
Exit;
while Idx >= Count do
AddObjectLen(nil, 0, 0);
Dest := PDWORD(DWORD(fTextBuf) + DWORD(fList.Items[Idx]));
Dest^ := Value;
end;
procedure TFastStrListEx.SetText(const S: ansistring; Append2List: Boolean);
var
Len2Add, NLines, L: Integer;
p0, p: PAnsiChar;
begin
if not Append2List then
Clear;
Len2Add := 0;
NLines := 0;
p := PAnsiChar(S);
p0 := p;
L := Length(S);
while L > 0 do
begin
if p^ = #13 then
begin
Inc(NLines);
Inc(Len2Add, 9 + DWORD(p) - DWORD(p0));
REPEAT
Inc(p);
Dec(L);
UNTIL (p^ <> #10) or (L = 0);
p0 := p;
end
else
begin
Inc(p);
Dec(L);
end;
end;
if DWORD(p) > DWORD(p0) then
begin
Inc(NLines);
Inc(Len2Add, 9 + DWORD(p) - DWORD(p0));
end;
if Len2Add = 0 then
Exit;
ProvideSpace(Len2Add - 9);
if fList.Capacity <= fList.Count + NLines then
fList.Capacity := Max((fList.Count + NLines) * 2, 100);
p := PAnsiChar(S);
p0 := p;
L := Length(S);
while L > 0 do
begin
if p^ = #13 then
begin
AddObjectLen(p0, DWORD(p) - DWORD(p0), 0);
REPEAT
Inc(p);
Dec(L);
UNTIL (p^ <> #10) or (L = 0);
p0 := p;
end
else
begin
Inc(p);
Dec(L);
end;
end;
if DWORD(p) > DWORD(p0) then
AddObjectLen(p0, DWORD(p) - DWORD(p0), 0);
end;
procedure TFastStrListEx.SetTextStr(const Value: ansistring);
begin
SetText(Value, FALSE);
end;
function CompareFast(const Data: Pointer; const e1, e2: DWORD): Integer;
var
FSL: PFastStrListEx;
L1, L2: Integer;
S1, S2: PAnsiChar;
begin
FSL := Data;
S1 := FSL.ItemPtrs[e1];
S2 := FSL.ItemPtrs[e2];
L1 := FSL.ItemLen[e1];
L2 := FSL.ItemLen[e2];
if FSL.fCaseSensitiveSort then
Result := StrLComp(S1, S2, Min(L1, L2))
else
Result := StrLComp_NoCase(S1, S2, Min(L1, L2));
if Result = 0 then
Result := L1 - L2;
if Result = 0 then
Result := e1 - e2;
end;
procedure SwapFast(const Data: Pointer; const e1, e2: DWORD);
var
FSL: PFastStrListEx;
begin
FSL := Data;
FSL.Swap(e1, e2);
end;
procedure TFastStrListEx.Sort(CaseSensitive: Boolean);
begin
fCaseSensitiveSort := CaseSensitive;
SortData(@Self, Count, CompareFast, SwapFast);
end;
procedure TFastStrListEx.Swap(Idx1, Idx2: Integer);
begin
Assert((Idx1 >= 0) and (Idx1 <= Count - 1) and (Idx2 >= 0) and
(Idx2 <= Count - 1), 'Item indexes violates TFastStrListEx range');
fList.Swap(Idx1, Idx2);
end;
function TFastStrListEx.GetValues(AName: PAnsiChar): PAnsiChar;
var
i: Integer;
S, n: PAnsiChar;
begin
if not Upper_Initialized then
InitUpper;
for i := 0 to Count - 1 do
begin
S := ItemPtrs[i];
n := AName;
while (Upper[S^] = Upper[n^]) and (S^ <> '=') and (S^ <> #0) and
(n^ <> #0) do
begin
Inc(S);
Inc(n);
end;
if (S^ = '=') and (n^ = #0) then
begin
Result := S;
Inc(Result);
Exit;
end;
end;
Result := nil;
end;
function TFastStrListEx.IndexOfName(AName: PAnsiChar): Integer;
var
i: Integer;
S, n: PAnsiChar;
begin
if not Upper_Initialized then
InitUpper;
for i := 0 to Count - 1 do
begin
S := ItemPtrs[i];
n := AName;
while (Upper[S^] = Upper[n^]) and (S^ <> '=') and (S^ <> #0) and
(n^ <> #0) do
begin
Inc(S);
Inc(n);
end;
if (S^ = '=') and (n^ = #0) then
begin
Result := i;
Exit;
end;
end;
Result := -1;
end;
end.