This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit a25032127bee8173aa7db3a3018f42c3ed35f277 Author: Shad Storhaug <[email protected]> AuthorDate: Mon Aug 24 20:05:02 2020 +0700 PERFORMANCE: Lucene.Net.Util.AttributeSource::GetAttribute<T>(): Removed extra lookup by using TryGetValue --- src/Lucene.Net/Util/AttributeSource.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Lucene.Net/Util/AttributeSource.cs b/src/Lucene.Net/Util/AttributeSource.cs index 74fc911..0f0ed10 100644 --- a/src/Lucene.Net/Util/AttributeSource.cs +++ b/src/Lucene.Net/Util/AttributeSource.cs @@ -437,11 +437,11 @@ namespace Lucene.Net.Util public virtual T GetAttribute<T>() where T : IAttribute { var attClass = typeof(T); - if (!attributes.ContainsKey(attClass)) + if (!attributes.TryGetValue(attClass, out var result)) { - throw new ArgumentException("this AttributeSource does not have the attribute '" + attClass.Name + "'."); + throw new ArgumentException($"this AttributeSource does not have the attribute '{attClass.Name}'."); } - return (T)(IAttribute)this.attributes[attClass]; + return (T)(IAttribute)result; } private State GetCurrentState()
