Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/PerformanceFixPrepareScr…
Browse files Browse the repository at this point in the history
…ipt'
  • Loading branch information
AndersMalmgren committed Mar 30, 2014
2 parents 3812963 + e318947 commit 829f87d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions FreePIE.Core/ScriptEngine/Globals/GlobalsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace FreePIE.Core.ScriptEngine.Globals
{
public static class GlobalsInfo
{
private static readonly Dictionary<Type, string> globalNamesCache = new Dictionary<Type, string>();

public static string GetGlobalName(object global)
{
var name = GetGlobalName(global.GetType());
Expand All @@ -22,10 +24,17 @@ public static string GetGlobalName(object global)

public static string GetGlobalName(Type type)
{
var typeAttribute = GetAttribute<GlobalType>(type);
var globalAttribute = typeAttribute != null ? GetAttribute<Global>(typeAttribute.Type) : GetAttribute<Global>(type);
if (!globalNamesCache.ContainsKey(type))
{
var typeAttribute = GetAttribute<GlobalType>(type);
var globalAttribute = typeAttribute != null
? GetAttribute<Global>(typeAttribute.Type)
: GetAttribute<Global>(type);

globalNamesCache[type] = globalAttribute != null ? globalAttribute.Name : null;
}

return globalAttribute != null ? globalAttribute.Name : null;
return globalNamesCache[type];
}

public static IEnumerable<MemberInfo> GetGlobalMembers(Type pluginType)
Expand Down
3 changes: 2 additions & 1 deletion FreePIE.Core/ScriptEngine/Python/PythonScriptParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ private string FindAndInitMethodsThatNeedIndexer(string script, IEnumerable<obje
var globalsThatNeedsIndex = globals
.SelectMany(g => g.GetType().GetMethods()
.Where(m => m.GetCustomAttributes(typeof(NeedIndexer), false).Length > 0)
.Select(m => new { Global = g, MethodInfo = m }));
.Select(m => new { Global = g, MethodInfo = m }))
.ToList();

for (int i = 0; i < script.Length; i++)
{
Expand Down

0 comments on commit 829f87d

Please sign in to comment.