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 2024/01/19 11:01:46 UTC
(lucenenet) branch master updated (85458d3c8 -> d740f13ea)
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
from 85458d3c8 Lucene.Net.Index.TestIndexWriterOnJRECrash::TestNRTThreads_Mem(): Added [AwaitsFix] attribute because this test fails intermittently (see #894).
new 8c3af72dd PERFORMANCE: Lucene.Net.Analysis.TokenAttributes.CharTermAttribute::Subsequence(): Changed to using Arrays.Copy() to copy the array instead of a for loop.
new d740f13ea PERFORMANCE: Lucene.Net.Analysis.TokenAttributes.CharTermAttribute::Append(): Use StringBuilder.CopyTo() to copy the chars instead of allocating a string.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../Analysis/TokenAttributes/CharTermAttributeImpl.cs | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
(lucenenet) 01/02: PERFORMANCE: Lucene.Net.Analysis.TokenAttributes.CharTermAttribute::Subsequence(): Changed to using Arrays.Copy() to copy the array instead of a for loop.
Posted by ni...@apache.org.
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 8c3af72dd78510a206f26b7341b88beff6c3262d
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Fri Jan 19 14:23:43 2024 +0700
PERFORMANCE: Lucene.Net.Analysis.TokenAttributes.CharTermAttribute::Subsequence(): Changed to using Arrays.Copy() to copy the array instead of a for loop.
---
src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs b/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs
index 206d8137a..c37541b40 100644
--- a/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs
+++ b/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs
@@ -190,9 +190,7 @@ namespace Lucene.Net.Analysis.TokenAttributes
throw new ArgumentOutOfRangeException(nameof(length), $"Index and length must refer to a location within the string. For example {nameof(startIndex)} + {nameof(length)} <= {nameof(Length)}.");
char[] result = new char[length];
- for (int i = 0, j = startIndex; i < length; i++, j++)
- result[i] = termBuffer[j];
-
+ Arrays.Copy(termBuffer, startIndex, result, 0, length);
return new CharArrayCharSequence(result);
}
(lucenenet) 02/02: PERFORMANCE: Lucene.Net.Analysis.TokenAttributes.CharTermAttribute::Append(): Use StringBuilder.CopyTo() to copy the chars instead of allocating a string.
Posted by ni...@apache.org.
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 d740f13ea160e3fcd556c497fd7e095c8a8c81d0
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Fri Jan 19 15:45:22 2024 +0700
PERFORMANCE: Lucene.Net.Analysis.TokenAttributes.CharTermAttribute::Append(): Use StringBuilder.CopyTo() to copy the chars instead of allocating a string.
---
src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs b/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs
index c37541b40..bd04b96d0 100644
--- a/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs
+++ b/src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs
@@ -279,7 +279,10 @@ namespace Lucene.Net.Analysis.TokenAttributes
return this; // No-op
}
- return Append(value.ToString());
+ int len = value.Length;
+ value.CopyTo(0, InternalResizeBuffer(termLength + len), termLength, len);
+ Length += len;
+ return this;
}
public CharTermAttribute Append(StringBuilder value, int startIndex, int charCount)
@@ -301,7 +304,9 @@ namespace Lucene.Net.Analysis.TokenAttributes
if (startIndex > value.Length - charCount)
throw new ArgumentOutOfRangeException(nameof(startIndex), $"Index and length must refer to a location within the string. For example {nameof(startIndex)} + {nameof(charCount)} <= {nameof(Length)}.");
- return Append(value.ToString(startIndex, charCount));
+ value.CopyTo(startIndex, InternalResizeBuffer(termLength + charCount), termLength, charCount);
+ Length += charCount;
+ return this;
}
public CharTermAttribute Append(ICharTermAttribute value)