/** * Compute the size of a tree entry record. * * This method can be used to estimate the correct size of a tree prior to * allocating a formatter. Getting the size correct at allocation time * ensures the internal buffer is sized correctly, reducing copying. * * @param mode * the mode the entry will have. * @param nameLen * the length of the name, in bytes. * @return the length of the record. */ public static int entrySize(FileMode mode, int nameLen) { return mode.copyToLength() + nameLen + OBJECT_ID_LENGTH + 2; }
private boolean fmtBuf(byte[] nameBuf, int namePos, int nameLen, FileMode mode) { if (buf == null || buf.length < ptr + entrySize(mode, nameLen)) return false; mode.copyTo(buf, ptr); ptr += mode.copyToLength(); buf[ptr++] = ' '; System.arraycopy(nameBuf, namePos, buf, ptr, nameLen); ptr += nameLen; buf[ptr++] = 0; return true; }
/** * Compute the size of a tree entry record. * * This method can be used to estimate the correct size of a tree prior to * allocating a formatter. Getting the size correct at allocation time * ensures the internal buffer is sized correctly, reducing copying. * * @param mode * the mode the entry will have. * @param nameLen * the length of the name, in bytes. * @return the length of the record. */ public static int entrySize(FileMode mode, int nameLen) { return mode.copyToLength() + nameLen + OBJECT_ID_LENGTH + 2; }
/** * Compute the size of a tree entry record. * * This method can be used to estimate the correct size of a tree prior to * allocating a formatter. Getting the size correct at allocation time * ensures the internal buffer is sized correctly, reducing copying. * * @param mode * the mode the entry will have. * @param nameLen * the length of the name, in bytes. * @return the length of the record. */ public static int entrySize(FileMode mode, int nameLen) { return mode.copyToLength() + nameLen + OBJECT_ID_LENGTH + 2; }
private boolean fmtBuf(byte[] nameBuf, int namePos, int nameLen, FileMode mode) { if (buf == null || buf.length < ptr + entrySize(mode, nameLen)) return false; mode.copyTo(buf, ptr); ptr += mode.copyToLength(); buf[ptr++] = ' '; System.arraycopy(nameBuf, namePos, buf, ptr, nameLen); ptr += nameLen; buf[ptr++] = 0; return true; }
private boolean fmtBuf(byte[] nameBuf, int namePos, int nameLen, FileMode mode) { if (buf == null || buf.length < ptr + entrySize(mode, nameLen)) return false; mode.copyTo(buf, ptr); ptr += mode.copyToLength(); buf[ptr++] = ' '; System.arraycopy(nameBuf, namePos, buf, ptr, nameLen); ptr += nameLen; buf[ptr++] = 0; return true; }