mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Use a buffered reader stream to minimize the read calls.
This commit is contained in:
parent
99aa0c76d4
commit
da030fa006
1 changed files with 5 additions and 3 deletions
|
@ -5,6 +5,7 @@ package org.eclipse.cdt.internal.parser;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -18,7 +19,7 @@ import java.util.List;
|
||||||
public class LinePositionInputStream extends InputStream {
|
public class LinePositionInputStream extends InputStream {
|
||||||
|
|
||||||
private List fLinePositions;
|
private List fLinePositions;
|
||||||
private InputStream fInputStream;
|
private BufferedInputStream buffered;
|
||||||
|
|
||||||
private boolean fRRead;
|
private boolean fRRead;
|
||||||
private boolean fAddLine;
|
private boolean fAddLine;
|
||||||
|
@ -26,7 +27,7 @@ public class LinePositionInputStream extends InputStream {
|
||||||
private int fCurrPosition;
|
private int fCurrPosition;
|
||||||
|
|
||||||
public LinePositionInputStream(InputStream inputStream) throws IOException {
|
public LinePositionInputStream(InputStream inputStream) throws IOException {
|
||||||
fInputStream= inputStream;
|
buffered = new BufferedInputStream(inputStream);
|
||||||
fLinePositions= new ArrayList(30);
|
fLinePositions= new ArrayList(30);
|
||||||
fAddLine= true;
|
fAddLine= true;
|
||||||
fRRead= false;
|
fRRead= false;
|
||||||
|
@ -34,7 +35,8 @@ public class LinePositionInputStream extends InputStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
int ch= fInputStream.read();
|
|
||||||
|
int ch = buffered.read();
|
||||||
if (fRRead && ch == '\n') {
|
if (fRRead && ch == '\n') {
|
||||||
fRRead= false;
|
fRRead= false;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue