private final String getPrefix(
            String namespace,
            boolean includeDefault,
            boolean create)
            throws IOException {

        for (int i = nspCounts[depth + 1] * 2 - 2; i >= 0; i -= 2) {
            if (nspStack[i + 1].equals(namespace)
                    && (includeDefault || StringUtils.isNotEmpty(nspStack[i]))) {
                String cand = nspStack[i];
                for (int j = i + 2; j < nspCounts[depth + 1] * 2; j++) {
                    if (nspStack[j].equals(cand)) {
                        cand = null;
                        break;
                    }
                }
                if (cand != null) {
                    return cand;
                }
            }
        }

        if (!create) {
            return null;
        }

        String prefix;

        if (StringUtils.isEmpty(namespace)) {
            prefix = "";
        } else {
            do {
                prefix = "n" + (auto++);
                for (int i = nspCounts[depth + 1] * 2 - 2; i >= 0; i -= 2) {
                    if (prefix.equals(nspStack[i])) {
                        prefix = null;
                        break;
                    }
                }
            } while (prefix == null);
        }

        boolean p = pending;
        pending = false;
        setPrefix(prefix, namespace);
        pending = p;
        return prefix;
    }
size (in characters) for the write buffer
main/thirdparty/cgeo/org/kxml2/io/KXmlSerializer.java