MutableAttributeSet mutable = createLargeAttributeSet(old); mutable.addAttribute(name, value); if (mutable.getAttributeCount() >= getCompressionThreshold()) return mutable; else { SmallAttributeSet small = createSmallAttributeSet(mutable); if (sharedAttributeSets.containsKey(small)) small = (SmallAttributeSet) sharedAttributeSets.get(small); else sharedAttributeSets.put(small,small); return small; }
MutableAttributeSet mas = getMutableAttributeSet(old); mas.addAttribute(name, value); ret = mas;
  public AttributeSet addAttribute(AttributeSet old, Object name, Object value)  {    if (old instanceof MutableAttributeSet)      {        ((MutableAttributeSet)old).addAttribute(name, value);        return old;      }    else       {        MutableAttributeSet mutable = createLargeAttributeSet(old);        mutable.addAttribute(name, value);        if (mutable.getAttributeCount() >= getCompressionThreshold())          return mutable;        else          {            SmallAttributeSet small = createSmallAttributeSet(mutable);            if (sharedAttributeSets.containsKey(small))              small = (SmallAttributeSet) sharedAttributeSets.get(small);            else              sharedAttributeSets.put(small,small);            return small;          }      }  }