Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions polymod/PolymodConfig.hx
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,30 @@ class PolymodConfig
*
* @default `true`
*/
public static var caseInsensitiveZipLoading(get, default):Null<Bool>;
public static var caseInsensitiveZipLoading(get, default):Null<Bool>;

static function get_caseInsensitiveZipLoading():Null<Bool>
{
static function get_caseInsensitiveZipLoading():Null<Bool>
{
if (caseInsensitiveZipLoading == null)
caseInsensitiveZipLoading = DefineUtil.getDefineBool('POLYMOD_ZIP_INSENSITIVE', true);
return caseInsensitiveZipLoading;
}
}

/**
* Whether the contents of text assets are cached, so that they're loaded faster.
* Don't enable this if mods need to modify these assets.
*
* Enable this option by setting the `POLYMOD_ENABLE_TEXT_CACHE` Haxe define at compile time,
* or by setting this value in your code.
*
* @default `false`
*/
public static var enableTextCache(get, default):Null<Bool>;

static function get_enableTextCache():Null<Bool>
{
if (enableTextCache == null)
enableTextCache = DefineUtil.getDefineBool('POLYMOD_ENABLE_TEXT_CACHE', false);
return enableTextCache;
}
}
12 changes: 8 additions & 4 deletions polymod/backends/PolymodAssetLibrary.hx
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,18 @@ class PolymodAssetLibrary
public function mergeAndAppendText(id:String, modText:String):String
{
var cacheKey = PolymodConfig.mergeFolder + id;
if (_textCache.exists(cacheKey))
if (PolymodConfig.enableTextCache && _textCache.exists(cacheKey))
{
return _textCache.get(cacheKey);
}

modText = Util.mergeAndAppendText(modText, id, dirs, getTextDirectly, fileSystem, parseRules);

_textCache.set(cacheKey, modText);
if (PolymodConfig.enableTextCache)
{
_textCache.set(cacheKey, modText);
}

return modText;
}

Expand Down Expand Up @@ -249,14 +253,14 @@ class PolymodAssetLibrary

public function getText(id:String):String
{
if (_textCache.exists(id))
if (PolymodConfig.enableTextCache && _textCache.exists(id))
{
return _textCache.get(id);
}

var result = backend.getText(id);

if (result != null)
if (PolymodConfig.enableTextCache && result != null)
{
_textCache.set(id, result);
}
Expand Down