1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 08:45:44 +02:00

Removal of old file cache from DOMScanner.

This commit is contained in:
John Camelon 2005-04-06 02:29:09 +00:00
parent 8b59056395
commit 082daae88f
3 changed files with 36 additions and 24 deletions

View file

@ -111,8 +111,6 @@ abstract class BaseScanner implements IScanner {
protected ExpressionEvaluator expressionEvaluator;
protected final CharArrayObjectMap fileCache = new CharArrayObjectMap(100);
// The context stack
protected static final int bufferInitialSize = 8;
@ -1226,9 +1224,6 @@ abstract class BaseScanner implements IScanner {
additionalKeywords = configuration.getAdditionalKeywords();
if (reader.filename != null)
fileCache.put(reader.filename, reader);
setupBuiltInMacros(configuration);
if (info.getDefinedSymbols() != null) {
@ -2865,25 +2860,8 @@ abstract class BaseScanner implements IScanner {
fileNameArray);
}
protected CodeReader createReader(String path, String fileName) {
String finalPath = ScannerUtility.createReconciledPath(path, fileName);
char[] finalPathc = finalPath.toCharArray();
CodeReader reader = (CodeReader) fileCache.get(finalPathc);
if (reader != null)
return reader; // found the file in the cache
protected abstract CodeReader createReader(String path, String fileName);
// create a new reader on this file (if the file does not exist we will
// get null)
reader = createReaderDuple(finalPath);
if (reader == null)
return null; // the file was not found
if (reader.filename != null)
// put the full requested path in the cache -- it is more likely
// to match next time than the reader.filename
fileCache.put(finalPathc, reader);
return reader;
}
private int findIncludePos(String[] paths, File currentDirectory) {
for (int i = 0; i < paths.length; ++i)

View file

@ -446,4 +446,11 @@ public class DOMScanner extends BaseScanner {
protected void afterReplaceAllMacros() {
--fsmCount;
}
protected CodeReader createReader(String path, String fileName){
String finalPath = ScannerUtility.createReconciledPath(path, fileName);
CodeReader reader = createReaderDuple(finalPath);
return reader;
}
}

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
import org.eclipse.cdt.internal.core.parser.token.ImagedExpansionToken;
import org.eclipse.cdt.internal.core.parser.token.ImagedToken;
@ -54,6 +55,9 @@ public class Scanner2 extends BaseScanner {
this.expressionEvaluator = new ExpressionEvaluator(callbackManager, spf);
this.workingCopies = workingCopies;
postConstructorSetup(reader, info);
if (reader.filename != null)
fileCache.put(reader.filename, reader);
}
/*
@ -225,6 +229,8 @@ public class Scanner2 extends BaseScanner {
protected static final ScannerProblemFactory spf = new ScannerProblemFactory();
protected final CharArrayObjectMap fileCache = new CharArrayObjectMap(100);
/*
* (non-Javadoc)
*
@ -332,4 +338,25 @@ public class Scanner2 extends BaseScanner {
protected void processPragma(int startPos, int endPos) {
}
protected CodeReader createReader(String path, String fileName){
String finalPath = ScannerUtility.createReconciledPath(path, fileName);
char[] finalPathc = finalPath.toCharArray();
CodeReader reader = (CodeReader) fileCache.get(finalPathc);
if (reader != null)
return reader; // found the file in the cache
// create a new reader on this file (if the file does not exist we will
// get null)
reader = createReaderDuple(finalPath);
if (reader == null)
return null; // the file was not found
if (reader.filename != null)
// put the full requested path in the cache -- it is more likely
// to match next time than the reader.filename
fileCache.put(finalPathc, reader);
return reader;
}
}