docs: private static void removeDuplicateAttributes(List<String> attrs) {
      int firstLetterMask = 0;
      int n = attrs.size();
      // attrs.subList(0, k) contains the non-duplicate parts of attrs that
      // have been processed thus far.
      int k = 0;
      attrLoop:
      for (int i = 0; i < n; i += 2) {
        String name = attrs.get(i);
  
        if (name.length() == 0) {
          continue attrLoop;
        }
  
        int firstCharIndex = name.charAt(0) - 'a';
        checkForDuplicate: {
          // Don't be O(n**2) in the common case by checking whether the first
          // letter has been seen on any other attribute.
          if (0 <= firstCharIndex && firstCharIndex <= 26) {
            int firstCharBit = 1 << firstCharIndex;
            if ((firstLetterMask & firstCharBit) == 0) {
              firstLetterMask = firstLetterMask | firstCharBit;
              break checkForDuplicate;
            }
          }
          // Look for a duplicate.
          for (int j = k; --j >= 0;) {
            if (attrs.get(j).equals(name)) {
              continue attrLoop;
            }
          }
        }
  
        // Preserve the attribute.
        if (k != i) {
          attrs.set(k, name);
          attrs.set(k + 1, attrs.get(i + 1));
        }
        k += 2;
      }
      if (k != n) {
        attrs.subList(k, n).clear();
      }
    }