Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/DataAccess.java @ 418:528b6780a8bd
A bit of FIXME cleanup (mostly degraded to TODO post 1.0), comments and javadoc
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 22 Mar 2012 21:02:20 +0100 |
parents | fdc1db8f7f61 |
children | 6c22bdc0bdfd |
comparison
equal
deleted
inserted
replaced
417:ccd7d25e5aea | 418:528b6780a8bd |
---|---|
85 return; | 85 return; |
86 } | 86 } |
87 throw new IOException(String.format("No data, can't read %d bytes", length)); | 87 throw new IOException(String.format("No data, can't read %d bytes", length)); |
88 } | 88 } |
89 // reads bytes into ByteBuffer, up to its limit or total data length, whichever smaller | 89 // reads bytes into ByteBuffer, up to its limit or total data length, whichever smaller |
90 // FIXME perhaps, in DataAccess paradigm (when we read known number of bytes, we shall pass specific byte count to read) | 90 // TODO post-1.0 perhaps, in DataAccess paradigm (when we read known number of bytes, we shall pass specific byte count to read) |
91 // for 1.0, it's ok as it's our internal class | |
91 public void readBytes(ByteBuffer buf) throws IOException { | 92 public void readBytes(ByteBuffer buf) throws IOException { |
92 // int toRead = Math.min(buf.remaining(), (int) length()); | 93 // int toRead = Math.min(buf.remaining(), (int) length()); |
93 // if (buf.hasArray()) { | 94 // if (buf.hasArray()) { |
94 // readBytes(buf.array(), buf.arrayOffset(), toRead); | 95 // readBytes(buf.array(), buf.arrayOffset(), toRead); |
95 // } else { | 96 // } else { |
96 // byte[] bb = new byte[toRead]; | 97 // byte[] bb = new byte[toRead]; |
97 // readBytes(bb, 0, bb.length); | 98 // readBytes(bb, 0, bb.length); |
98 // buf.put(bb); | 99 // buf.put(bb); |
99 // } | 100 // } |
100 // FIXME optimize to read as much as possible at once | 101 // TODO post-1.0 optimize to read as much as possible at once |
101 while (!isEmpty() && buf.hasRemaining()) { | 102 while (!isEmpty() && buf.hasRemaining()) { |
102 buf.put(readByte()); | 103 buf.put(readByte()); |
103 } | 104 } |
104 } | 105 } |
105 public byte readByte() throws IOException { | 106 public byte readByte() throws IOException { |