code: private static void _smartAppend(StringBuilder buf, char c) {
          if (buf.length() != 0 &&
              buf.charAt(buf.length() - 1) != c) {
              buf.append(c);
          }
      }
docs: Append c to buf, unless buf is empty or buf already ends in c.