mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 197989: Use limited LRU caches instead of the unlimited ones.
This commit is contained in:
parent
0fb12d7d56
commit
87c046746f
2 changed files with 36 additions and 3 deletions
|
@ -0,0 +1,32 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2011 Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.parser.util;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LRUCache based on {@link LinkedHashMap}.
|
||||||
|
*/
|
||||||
|
public class LRUCache<K, V> extends LinkedHashMap<K, V> {
|
||||||
|
private int fLimit;
|
||||||
|
|
||||||
|
public LRUCache(int limit) {
|
||||||
|
super(16, 0.75f, true);
|
||||||
|
fLimit= limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean removeEldestEntry(Entry<K, V> eldest) {
|
||||||
|
return size() >= fLimit;
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,6 +54,7 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedFileContentProvider;
|
import org.eclipse.cdt.internal.core.index.IndexBasedFileContentProvider;
|
||||||
import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
|
import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider;
|
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.LRUCache;
|
||||||
import org.eclipse.cdt.utils.EFSExtensionManager;
|
import org.eclipse.cdt.utils.EFSExtensionManager;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -270,15 +271,15 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected enum MessageKind { parsingFileTask, errorWhileParsing, tooManyIndexProblems }
|
protected enum MessageKind { parsingFileTask, errorWhileParsing, tooManyIndexProblems }
|
||||||
|
|
||||||
private int fUpdateFlags= IIndexManager.UPDATE_ALL;
|
private int fUpdateFlags= IIndexManager.UPDATE_ALL;
|
||||||
private UnusedHeaderStrategy fIndexHeadersWithoutContext= UnusedHeaderStrategy.useDefaultLanguage;
|
private UnusedHeaderStrategy fIndexHeadersWithoutContext= UnusedHeaderStrategy.useDefaultLanguage;
|
||||||
private boolean fIndexFilesWithoutConfiguration= true;
|
private boolean fIndexFilesWithoutConfiguration= true;
|
||||||
private List<LinkageTask> fRequestsPerLinkage= new ArrayList<LinkageTask>();
|
private List<LinkageTask> fRequestsPerLinkage= new ArrayList<LinkageTask>();
|
||||||
private Map<IIndexFile, IndexFileContent> fIndexContentCache= new HashMap<IIndexFile, IndexFileContent>();
|
private Map<IIndexFile, IndexFileContent> fIndexContentCache= new LRUCache<IIndexFile, IndexFileContent>(500);
|
||||||
private Map<IIndexFileLocation, IIndexFile[]> fIndexFilesCache= new HashMap<IIndexFileLocation, IIndexFile[]>();
|
private Map<IIndexFileLocation, IIndexFile[]> fIndexFilesCache= new LRUCache<IIndexFileLocation, IIndexFile[]>(5000);
|
||||||
|
|
||||||
private Object[] fFilesToUpdate;
|
private Object[] fFilesToUpdate;
|
||||||
private List<Object> fFilesToRemove = new ArrayList<Object>();
|
private List<Object> fFilesToRemove = new ArrayList<Object>();
|
||||||
|
|
Loading…
Add table
Reference in a new issue