Improved efficiency of startup methods.
- ShpReader will copy the input stream into memory just once rather than for every header. - ShpReader.CopyImageData switched to use Array.Copy since that uses some unsafe magic for speed. - In ActorInfo, cache a GetType call and prevent needless materialization in PrerequisitesOf. - In ObjectCreator, cache type and ctor lookups since these are expensive and often repeated. - Implement IReadOnlyDictionary<T, U> on Cache<T, U> to provide some supplementary functions. - In TechTree.GatherOwnedPrerequisites, rearrange a Boolean 'and' expression to evaluate expensive functions later in the chain, and use ContainsKey to speed up name check.
This commit is contained in:
@@ -25,8 +25,8 @@ namespace OpenRA
|
||||
{
|
||||
int Count { get; }
|
||||
TValue this[TKey key] { get; }
|
||||
IEnumerable<TKey> Keys { get; }
|
||||
IEnumerable<TValue> Values { get; }
|
||||
ICollection<TKey> Keys { get; }
|
||||
ICollection<TValue> Values { get; }
|
||||
|
||||
bool ContainsKey(TKey key);
|
||||
bool TryGetValue(TKey key, out TValue value);
|
||||
@@ -68,9 +68,9 @@ namespace OpenRA
|
||||
|
||||
public TValue this[TKey key] { get { return dict[key]; } }
|
||||
|
||||
public IEnumerable<TKey> Keys { get { return dict.Keys; } }
|
||||
public ICollection<TKey> Keys { get { return dict.Keys; } }
|
||||
|
||||
public IEnumerable<TValue> Values { get { return dict.Values; } }
|
||||
public ICollection<TValue> Values { get { return dict.Values; } }
|
||||
#endregion
|
||||
|
||||
#region IEnumerable implementation
|
||||
|
||||
Reference in New Issue
Block a user