Skip to content
This repository has been archived by the owner on Mar 6, 2018. It is now read-only.

Commit

Permalink
Fix speed issues with chunk loading under Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
hach-que committed Dec 21, 2013
1 parent 831bb29 commit 379e4a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Protogame/Assets/DefaultTransparentAssetCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public IAsset HandlePlatform(IAsset asset, TargetPlatform platform, bool force =
var compiler = this.m_Kernel.TryGet(compilerType);
if (compiler == null)
{
throw new AssetNotCompiledException(asset.Name);
// The caller will throw AssetNotCompiledException if all of the candidates
// for loading only have source information.
return asset;
}
var proxyType = typeof(AssetCompilerProxy<>).MakeGenericType(asset.GetType());
var proxy = (IAssetCompilerProxyInterface)
Expand Down
20 changes: 17 additions & 3 deletions Protogame/Assets/LocalAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public class LocalAsset : IAsset
private LocalAssetManager Manager { get; set; }

private IAsset m_Instance;


private IAsset m_CachedProxy;

public event EventHandler Dirtied;

/// <summary>
Expand Down Expand Up @@ -62,20 +64,32 @@ public IAsset Instance
{
get
{
return this.FormProxyIfPossible(this.m_Instance);
return this.GetProxy(this.m_Instance);
}
}

public T Resolve<T>() where T : class, IAsset
{
if (this.m_Instance is T)
{
return this.FormProxyIfPossible(this.m_Instance as T);
return this.GetProxy(this.m_Instance as T);
}
throw new InvalidOperationException(
"Local asset can not be resolved");
}

private T GetProxy<T>(T obj) where T : class, IAsset
{
if (this.m_CachedProxy != null)
{
return this.m_CachedProxy as T;
}

var proxy = this.FormProxyIfPossible(obj);
this.m_CachedProxy = proxy;
return proxy;
}

private T FormProxyIfPossible<T>(T obj) where T : class, IAsset
{
if (!typeof(MarshalByRefObject).IsAssignableFrom(obj.GetType()))
Expand Down

0 comments on commit 379e4a0

Please sign in to comment.