code: @Override
      public UnicodeSet freeze() {
          if (!isFrozen()) {
              // Do most of what compact() does before freezing because
              // compact() will not work when the set is frozen.
              // Small modification: Don't shrink if the savings would be tiny (<=GROW_EXTRA).
  
              // Delete buffer first to defragment memory less.
              buffer = null;
              if (list.length > (len + GROW_EXTRA)) {
                  // Make the capacity equal to len or 1.
                  // We don't want to realloc of 0 size.
                  int capacity = (len == 0) ? 1 : len;
                  int[] oldList = list;
                  list = new int[capacity];
                  for (int i = capacity; i-- > 0;) {
                      list[i] = oldList[i];
                  }
              }
  
              // Optimize contains() and span() and similar functions.
              if (!strings.isEmpty()) {
                  stringSpan = new UnicodeSetStringSpan(this, new ArrayList<String>(strings), UnicodeSetStringSpan.ALL);
              }
              if (stringSpan == null || !stringSpan.needsStringSpanUTF16()) {
                  // Optimize for code point spans.
                  // There are no strings, or
                  // all strings are irrelevant for span() etc. because
                  // all of each string's code points are contained in this set.
                  // However, fully contained strings are relevant for spanAndCount(),
                  // so we create both objects.
                  bmpSet = new BMPSet(list, len);
              }
          }
          return this;
      }
docs: Freeze this class, according to the Freezable interface.
  
  @return this