anchor.diff:        end;
     strict private
       FStringToId : TDictionary<TStringRec, TStringId>;
  -    FRefCount : NativeUInt;
  +    FRefCount : NativeInt;
       FIsPersistent : Boolean;
   
       class var FInstance : TStringCache;
  
positive.code:   Inc(FUsageCount);
  end;
  
  { TStringCacheDictionary<TKey> }
  
  constructor TStringCacheDictionary<TKey>.Create;
  begin
    inherited;
    FKeyToId := TDictionary<TKey, TStringId>.Create;
    TStringCache.Instance.IncRef; // Uses the cache
  end;
  
  destructor TStringCacheDictionary<TKey>.Destroy;
  begin
    FKeyToId.Free;
    TStringCache.Instance.DecRef;
    inherited;
  end;
  
  function TStringCacheDictionary<TKey>.GetItem(const Key: TKey): string;
  var
    ID : TStringId;
  begin
    if FKeyToId.TryGetValue(Key, ID) then
      Result := TStringCache.Instance.Get(ID)
    else
      Result := '';
  end;
  
  procedure TStringCacheDictionary<TKey>.SetItem(const Key: TKey; const Value: string);
  begin
    FKeyToId.AddOrSetValue(Key, TStringCache.Instance.Add(Value));
  end;
  
  function TStringCacheDictionary<TKey>.GetCount : Integer;
  begin
    Result := FKeyToId.Count;
  end;
  
  function TStringCacheDictionary<TKey>.TryGetValue(const Key: TKey; out Value: string): Boolean;
  var
    ID : TStringId;
  begin
    Result := FKeyToId.TryGetValue(Key, ID);
    if Result then
      Value := TStringCache.Instance.Get(ID);
  end;
  
  procedure TStringCacheDictionary<TKey>.AddOrSetValue(const Key: TKey; const Value: string);
  begin
    SetItem(Key, Value);
  end;
  
  function TStringCacheDictionary<TKey>.ContainsKey(const Key: TKey): Boolean;
  begin
    Result := FKeyToId.ContainsKey(Key);
  end;
  
  function TStringCacheDictionary<TKey>.ToArray: TArray<TPair<TKey, string>>;
  var
    Value: TPair<TKey, string>;
    I : Integer;
  begin
    SetLength(Result, Count);
    I := 0;
    for Value in Self do begin
      Result[I] := Value;
      Inc(I);
    end;
  end;
  
  function TStringCacheDictionary<TKey>.DoGetEnumerator: TEnumerator<TPair<TKey, string>>;
  begin
    Result := TKeyStringEnumerator.Create(Self);
  end;
  
  { TStringCacheDictionary<TKey>.TKeyStringEnumerator }
  
  constructor TStringCacheDictionary<TKey>.TKeyStringEnumerator.Create(const ADictionary: TStringCacheDictionary<TKey>);
  begin
    inherited Create();
    FDictionary := ADictionary;
    FInternalEnum := FDictionary.FKeyToId.GetEnumerator;
  end;
  
  destructor TStringCacheDictionary<TKey>.TKeyStringEnumerator.Destroy;
  begin
    FInternalEnum.Free;
    inherited;
  end;
  
  function TStringCacheDictionary<TKey>.TKeyStringEnumerator.DoGetCurrent: TPair<TKey, string>;
  var
    Pair : TPair<TKey, TStringId>;
  begin
    // Wrap the owner dictionary's internal FKeyToId enumerator, converting ID to string
    Pair := FInternalEnum.Current;
    Result := TPair<TKey, string>.Create(Pair.Key, FDictionary.Items[Pair.Key]);
  end;
  
  function TStringCacheDictionary<TKey>.TKeyStringEnumerator.DoMoveNext: Boolean;
  begin
    Result := FInternalEnum.MoveNext;
  end;
  
  end.
  
negative.code:     class property Instance : TStringCache read FInstance;
    end;
  
  implementation
  
  uses
  