private int ComputeSize(DirCacheEntry[] cache, int cIdx, int pathOffset, ObjectWriter ow)
{
int endIdx = cIdx + _entrySpan;
int childIdx = 0;
int entryIdx = cIdx;
int size = 0;
while (entryIdx < endIdx)
{
DirCacheEntry e = cache[entryIdx];
if (e.getStage() != 0)
{
throw new UnmergedPathException(e);
}
byte[] ep = e.Path;
if (childIdx < _childCount)
{
DirCacheTree st = _children[childIdx];
if (st.contains(ep, pathOffset, ep.Length))
{
int stOffset = pathOffset + st.nameLength() + 1;
st.writeTree(cache, entryIdx, stOffset, ow);
size += FileMode.Tree.copyToLength();
size += st.nameLength();
size += Constants.OBJECT_ID_LENGTH + 2;
entryIdx += st._entrySpan;
childIdx++;
continue;
}
}
FileMode mode = e.getFileMode();
size += mode.copyToLength();
size += ep.Length - pathOffset;
size += Constants.OBJECT_ID_LENGTH + 2;
entryIdx++;
}
return(size);
}