Skip to content

Commit 9c19648

Browse files
committed
Remove CharBuffer overloads
1 parent e2e60c0 commit 9c19648

4 files changed

Lines changed: 11 additions & 86 deletions

File tree

src/Lucene.Net.Facet/Taxonomy/WriterCache/CharBlockArray.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -186,44 +186,6 @@ public virtual CharBlockArray Append(CharBlockArray? value, int startIndex, int
186186
return this;
187187
}
188188

189-
public virtual CharBlockArray Append(CharBuffer? value)
190-
{
191-
if (value is null)
192-
{
193-
return this; // No-op
194-
}
195-
196-
return Append(value, 0, value.Length);
197-
}
198-
199-
public virtual CharBlockArray Append(CharBuffer? value, int startIndex, int length)
200-
{
201-
// LUCENENET: Changed semantics to be the same as the StringBuilder in .NET
202-
if (startIndex < 0)
203-
throw new ArgumentOutOfRangeException(nameof(startIndex), $"{nameof(startIndex)} must not be negative.");
204-
if (length < 0)
205-
throw new ArgumentOutOfRangeException(nameof(length), $"{nameof(length)} must not be negative.");
206-
207-
if (value is null)
208-
{
209-
if (startIndex == 0 && length == 0)
210-
return this;
211-
throw new ArgumentNullException(nameof(value));
212-
}
213-
if (length == 0)
214-
return this;
215-
if (startIndex > value.Length - length)
216-
throw new ArgumentOutOfRangeException(nameof(startIndex), $"Index and length must refer to a location within the string. For example {nameof(startIndex)} + {nameof(length)} <= {nameof(Length)}.");
217-
218-
int end = startIndex + length;
219-
for (int i = startIndex; i < end; i++)
220-
{
221-
Append(value[i]);
222-
}
223-
224-
return this;
225-
}
226-
227189
public virtual CharBlockArray Append(StringBuilder? value)
228190
{
229191
if (value is null) // needed for Appendable compliance

src/Lucene.Net.Tests.Facet/Taxonomy/WriterCache/TestCharBlockArray.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ public virtual void TestAppendableInterface()
141141
t.Append(new StringBuilder(t.ToString())); // LUCENENET: StringBuilder doesn't implement ICharSequence
142142
Assert.AreEqual("123456789012341234567890123456123456789012341234567890123456", t.ToString());
143143
// very wierd, to test if a subSlice is wrapped correct :)
144-
CharBuffer buf = CharBuffer.Wrap("0123456789".ToCharArray(), 3, 5);
144+
var buf = "0123456789".ToCharArray().AsSpan(3, 5);
145145
Assert.AreEqual("34567", buf.ToString());
146146
t = new CharBlockArray();
147-
t.Append(buf, 1, 2 - 1); // LUCENENET: Corrected 3rd parameter
147+
t.Append(buf.Slice(1, 2 - 1)); // LUCENENET: Corrected 3rd parameter
148148
Assert.AreEqual("4", t.ToString());
149149
CharBlockArray t2 = new CharBlockArray();
150150
t2.Append("test");
@@ -261,10 +261,10 @@ public virtual void TestAppendableInterfaceWithLongSequences()
261261
t.Append(new StringBuilder(t.ToString()));
262262
Assert.AreEqual("567890123456567890123456", t.ToString());
263263
// very wierd, to test if a subSlice is wrapped correct :)
264-
CharBuffer buf = CharBuffer.Wrap("012345678901234567890123456789".ToCharArray(), 3, 15);
264+
var buf = "012345678901234567890123456789".ToCharArray().AsSpan(3, 15);
265265
Assert.AreEqual("345678901234567", buf.ToString());
266266
t = new CharBlockArray();
267-
t.Append(buf, 1, 14 - 1);
267+
t.Append(buf.Slice(1, 14 - 1));
268268
Assert.AreEqual("4567890123456", t.ToString());
269269

270270
// finally use a completely custom ReadOnlySpan<char> that is not catched by instanceof checks

src/Lucene.Net.Tests/Analysis/TokenAttributes/TestCharTermAttributeImpl.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ public virtual void TestAppendableInterface()
182182
Assert.AreEqual("12345678901234", t.ToString());
183183
t.Append(t.ToString()); // LUCENENET: CharTermAttribute no longer implements ICharSequence
184184
Assert.AreEqual("1234567890123412345678901234", t.ToString());
185-
t.Append(new StringBuilder("0123456789").ToString().AsSpan(5, 7 - 5)); // LUCENENET: StringBuilder doesn't implement ICharSequence, corrected 3rd argument
185+
t.Append(new StringBuilder("0123456789").ToString().AsSpan(5, 7 - 5)); // LUCENENET: StringBuilder doesn't implement ICharSequence, corrected argument
186186
Assert.AreEqual("123456789012341234567890123456", t.ToString());
187187
t.Append(new StringBuilder(t.ToString()));
188188
Assert.AreEqual("123456789012341234567890123456123456789012341234567890123456", t.ToString()); // LUCENENET: StringBuilder doesn't implement ICharSequence
189189
// very wierd, to test if a subSlice is wrapped correct :)
190-
CharBuffer buf = CharBuffer.Wrap("0123456789".ToCharArray(), 3, 5);
190+
var buf = "0123456789".ToCharArray().AsSpan(3, 5);
191191
Assert.AreEqual("34567", buf.ToString());
192-
t.SetEmpty().Append(buf, 1, 2 - 1); // LUCENENET: Corrected 3rd parameter
192+
t.SetEmpty().Append(buf.Slice(1, 2 - 1)); // LUCENENET: Corrected parameter
193193
Assert.AreEqual("4", t.ToString());
194194
ICharTermAttribute t2 = new CharTermAttribute();
195195
t2.Append("test");
@@ -210,7 +210,7 @@ public virtual void TestAppendableInterface()
210210

211211
try
212212
{
213-
t.Append(t2.AsSpan(1, 0 - 1)); // LUCENENET: Corrected 3rd parameter
213+
t.Append(t2.AsSpan(1, 0 - 1)); // LUCENENET: Corrected parameter
214214
Assert.Fail("Should throw ArgumentOutOfRangeException");
215215
}
216216
catch (ArgumentOutOfRangeException /*iobe*/)
@@ -284,17 +284,17 @@ public virtual void TestAppendableInterfaceWithLongSequences()
284284
Assert.AreEqual("0123456789012345678901234567890123456789012345678934567890123456789012345678901234567890123456789", t.ToString());
285285
t.SetEmpty();
286286
t.Append("01234567890123456789012345678901234567890123456789".AsSpan());
287-
t.Append(CharBuffer.Wrap("01234567890123456789012345678901234567890123456789".ToCharArray()), 3, 50 - 3); // LUCENENET: Corrected 3rd parameter
287+
t.Append("01234567890123456789012345678901234567890123456789".ToCharArray().AsSpan(3, 50 - 3)); // LUCENENET: Corrected parameter
288288
// "01234567890123456789012345678901234567890123456789"
289289
Assert.AreEqual("0123456789012345678901234567890123456789012345678934567890123456789012345678901234567890123456789", t.ToString());
290290
t.SetEmpty().Append(new StringBuilder("01234567890123456789"), 5, 17 - 5); // LUCENENET: StringBuilder doesn't implement ICharSequence
291291
Assert.AreEqual("567890123456", t.ToString());
292292
t.Append(new StringBuilder(t.ToString()));
293293
Assert.AreEqual("567890123456567890123456", t.ToString());
294294
// very wierd, to test if a subSlice is wrapped correct :)
295-
CharBuffer buf = CharBuffer.Wrap("012345678901234567890123456789".ToCharArray(), 3, 15);
295+
var buf = "012345678901234567890123456789".ToCharArray().AsSpan(3, 15);
296296
Assert.AreEqual("345678901234567", buf.ToString());
297-
t.SetEmpty().Append(buf, 1, 14 - 1);
297+
t.SetEmpty().Append(buf.Slice(1, 14 - 1));
298298
Assert.AreEqual("4567890123456", t.ToString());
299299

300300
// finally use a completely custom ReadOnlySpan that is not catched by instanceof checks

src/Lucene.Net/Analysis/TokenAttributes/CharTermAttributeImpl.cs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -210,43 +210,6 @@ public CharTermAttribute Append(StringBuilder value, int startIndex, int charCou
210210
return this;
211211
}
212212

213-
public CharTermAttribute Append(CharBuffer value)
214-
{
215-
if (value is null)
216-
{
217-
return this; // No-op
218-
}
219-
220-
return Append(value, 0, value.Length);
221-
}
222-
223-
public CharTermAttribute Append(CharBuffer value, int startIndex, int charCount)
224-
{
225-
if (startIndex < 0)
226-
throw new ArgumentOutOfRangeException(nameof(startIndex), $"{nameof(startIndex)} must not be negative.");
227-
if (charCount < 0)
228-
throw new ArgumentOutOfRangeException(nameof(charCount), $"{nameof(charCount)} must not be negative.");
229-
230-
if (value is null)
231-
{
232-
if (startIndex == 0 && charCount == 0)
233-
return this;
234-
throw new ArgumentNullException(nameof(value));
235-
}
236-
if (charCount == 0)
237-
return this;
238-
if (startIndex > value.Length - charCount)
239-
throw new ArgumentOutOfRangeException(nameof(startIndex), $"Index and length must refer to a location within the string. For example {nameof(startIndex)} + {nameof(charCount)} <= {nameof(Length)}.");
240-
241-
int end = startIndex + charCount;
242-
for (int i = startIndex; i < end; i++)
243-
{
244-
Append(value[i]);
245-
}
246-
247-
return this;
248-
}
249-
250213
public CharTermAttribute Append(ICharTermAttribute value)
251214
{
252215
if (value is null) // needed for Appendable compliance

0 commit comments

Comments
 (0)