diff --git a/src/ce_common.pas b/src/ce_common.pas index 0bd0e4c6..deaaa488 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -230,6 +230,10 @@ type *) function isStringDisabled(const str: string): boolean; + (** + * Deletes the duplicates in a TStrings instance. + *) + procedure deleteDups(str: TStrings); implementation @@ -1050,6 +1054,19 @@ begin result := true; end; +procedure deleteDups(str: TStrings); +var + i: integer; +begin + {$HINTS OFF} + if str = nil then exit; + for i:= str.Count-1 downto 0 do + // if less than 0 -> not found -> unsigned -> greater than current index. + if cardinal(str.IndexOf(str.Strings[i])) < i then + str.Delete(i); + {$HINTS ON} +end; + initialization registerClasses([TCEPersistentShortcut]); end.