Skip to content

Commit

Permalink
Fix lag caused by entity creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyvv committed Aug 16, 2021
1 parent 0747db2 commit 8925790
Show file tree
Hide file tree
Showing 3 changed files with 447 additions and 260 deletions.
11 changes: 8 additions & 3 deletions src/Alex.MoLang/Runtime/Struct/VariableStruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public virtual void Set(MoPath key, IMoValue value)

if (!key.HasChildren)
{
Map[key.ToString()] = value;
Map[key.Segment] = value;

return;
}
Expand All @@ -48,8 +48,13 @@ public virtual void Set(MoPath key, IMoValue value)
//object vstruct = Get(main, MoParams.Empty);

if (!Map.TryGetValue(main, out var container)) {
if (!key.HasChildren)
{
//Map.TryAdd(main, container = new VariableStruct());
throw new MoLangRuntimeException($"Variable was not a struct: {key}", null);
}

Map.TryAdd(main, container = new VariableStruct());
// throw new MoLangRuntimeException($"Variable was not a struct: {key}", null);
}

if (container is IMoStruct moStruct)
Expand Down Expand Up @@ -95,7 +100,7 @@ public virtual IMoValue Get(MoPath key, MoParams parameters)
}
}

if (Map.TryGetValue(key.ToString(), out var v))
if (Map.TryGetValue(key.Segment, out var v))
return v;

//
Expand Down
Loading

0 comments on commit 8925790

Please sign in to comment.