intern method

String intern(
  1. String s
)

Returns the canonical string equal to s; deduplicates repeated strings.

Implementation

String intern(String s) {
  final String? existing = _pool[s];
  if (existing != null) return existing;
  if (_maxSize != null && _order != null && _order.length >= _maxSize) {
    final String evict = _order.removeAt(0);
    _pool.remove(evict);
  }
  _pool[s] = s;
  if (_order != null) _order.add(s);
  return s;
}