Ensure RawParseUtils.lineMap last element is the buffer end
commitddbc872484ee72914d48a30db8011e89cba10e54
authorShawn O. Pearce <spearce@spearce.org>
Fri, 20 Mar 2009 16:38:08 +0000 (20 09:38 -0700)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Fri, 20 Mar 2009 21:35:04 +0000 (20 22:35 +0100)
tree240d0d4b9f22d912a7593beeada2d821cecf5f01
parentf9a118ebd98d27b937e497cb95bd0cdcc921348b
Ensure RawParseUtils.lineMap last element is the buffer end

Application code is easier to write when we can assume that for
any given source line the last element of the IntList returned
by lineMap contains the value of the end parameter.  This makes
it easy to extract any line by saying:

  RawParseUtils.decodeNoFallback(
    Constants.CHARSET,
    buf,
lineMap.get(lineNbr),
    lineMap.get(lineNbr + 1));

without needing to worry about bound checks, assuming of course
that lineNbr is already bound-checked within the range of the file.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit.test/tst/org/spearce/jgit/util/RawParseUtils_LineMapTest.java
org.spearce.jgit/src/org/spearce/jgit/util/RawParseUtils.java