1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Updated the CodeReaderCache to make it easier to test w/performance JUnits.

This commit is contained in:
John Camelon 2005-04-22 17:49:54 +00:00
parent 7aef086165
commit 90c4d131cc
4 changed files with 35 additions and 4 deletions

View file

@ -45,4 +45,9 @@ public interface ICodeReaderCache {
* @return
*/
public int getCurrentSpace();
/**
*
*/
public void flush();
}

View file

@ -62,4 +62,9 @@ public class EmptyCodeReaderCache implements ICodeReaderCache {
return 0;
}
public void flush() {
// nothing to do
}
}

View file

@ -295,4 +295,8 @@ public class CodeReaderCache implements ICodeReaderCache {
return cache.getCurrentSpace();
}
public void flush() {
cache.flush();
}
}

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.CodeReaderCache;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.core.runtime.Preferences;
/**
* @author jcamelon
@ -34,13 +35,29 @@ public class SavedCodeReaderFactory implements ICodeReaderFactory {
private SavedCodeReaderFactory()
{
int size=0;
if (CCorePlugin.getDefault() == null || CCorePlugin.getDefault().getPluginPreferences() == null)
Preferences pluginPreferences = CCorePlugin.getDefault().getPluginPreferences();
if (CCorePlugin.getDefault() == null || pluginPreferences == null)
size = CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB;
else
size = CCorePlugin.getDefault().getPluginPreferences().getInt(CodeReaderCache.CODE_READER_BUFFER);
if (size >= 0)
size = pluginPreferences.getInt(CodeReaderCache.CODE_READER_BUFFER);
if (size > 0)
cache = new CodeReaderCache(size);
else if( size == 0 )
{
//necessary for cache to work headless
String [] properties = pluginPreferences.propertyNames();
boolean found = false;
for( int j = 0; j < properties.length; ++j )
if( properties[j].equals( CodeReaderCache.CODE_READER_BUFFER ) )
{
found = true;
break;
}
if( !found && size == 0 )
cache = new CodeReaderCache(CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
}
else
cache = new CodeReaderCache(CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
}