You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2020/06/24 18:12:16 UTC
[lucenenet] 22/26:
Lucene.Net.Tests.Facet.Taxonomy.WriterCache.TestCharBlockArray::TestArray():
Optimized by comparing against string,
since indexing into a StringBuilder is painfully slow in .NET
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 941b62b9bf4626ce9ebe9c6f1ef204c8ae439de3
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Wed Jun 24 20:01:49 2020 +0700
Lucene.Net.Tests.Facet.Taxonomy.WriterCache.TestCharBlockArray::TestArray(): Optimized by comparing against string, since indexing into a StringBuilder is painfully slow in .NET
---
.../Taxonomy/WriterCache/TestCharBlockArray.cs | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCharBlockArray.cs b/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCharBlockArray.cs
index b291ff7..511464f 100644
--- a/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCharBlockArray.cs
+++ b/src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCharBlockArray.cs
@@ -26,7 +26,6 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
[TestFixture]
public class TestCharBlockArray : FacetTestCase
{
-
[Test, LongRunningTest]
public virtual void TestArray()
{
@@ -111,10 +110,13 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
private static void AssertEqualsInternal(string msg, StringBuilder expected, CharBlockArray actual)
{
- Assert.AreEqual(expected.Length, actual.Length, msg);
- for (int i = 0; i < expected.Length; i++)
+ // LUCENENET specific - Indexing a string is much faster than StringBuilder (#295)
+ var expected2 = expected.ToString();
+ var expected2Len = expected2.Length;
+ Assert.AreEqual(expected2Len, actual.Length, msg);
+ for (int i = 0; i < expected2Len; i++)
{
- Assert.AreEqual(expected[i], actual[i], msg);
+ Assert.AreEqual(expected2[i], actual[i], msg);
}
}
}