Skip to content

Commit c21f49f

Browse files
committed
Remove CharBuffer interface
We had this for when the double library was in a separate module. That's no longer the case, so we can delete it now.
1 parent fb0f323 commit c21f49f

File tree

3 files changed

+11
-48
lines changed

3 files changed

+11
-48
lines changed

src/main/java/cc/tweaked/cobalt/internal/doubles/CharBuffer.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/main/java/cc/tweaked/cobalt/internal/doubles/DoubleToStringConverter.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
package cc.tweaked.cobalt.internal.doubles;
3333

3434
import org.checkerframework.checker.signedness.qual.Unsigned;
35+
import org.squiddev.cobalt.Buffer;
3536

3637
import static cc.tweaked.cobalt.internal.doubles.Assert.requireArg;
3738

@@ -120,7 +121,7 @@ private DoubleToStringConverter() {
120121
* If either of them is NULL or the value is not special then the
121122
* function returns false.
122123
*/
123-
private static void handleSpecialValues(double value, FormatOptions fo, CharBuffer resultBuilder) {
124+
private static void handleSpecialValues(double value, FormatOptions fo, Buffer resultBuilder) {
124125
boolean sign = value < 0.0;
125126

126127
int effectiveWidth = fo.width();
@@ -164,7 +165,7 @@ private static void createExponentialRepresentation(
164165
int length,
165166
int exponent,
166167
FormatOptions fo,
167-
CharBuffer resultBuilder
168+
Buffer resultBuilder
168169
) {
169170
requireArg(decimalDigits.length() != 0, "decimalDigits must not be empty");
170171
requireArg(length <= decimalDigits.length(), "length must be smaller than decimalDigits");
@@ -246,7 +247,7 @@ private static void createDecimalRepresentation(
246247
double value,
247248
int digitsAfterPoint,
248249
FormatOptions fo,
249-
CharBuffer resultBuilder
250+
Buffer resultBuilder
250251
) {
251252
int decimalPoint = decimalDigits.getPointPosition();
252253
int digitsLength = decimalDigits.length();
@@ -395,7 +396,7 @@ private static int calculateExpWidth(
395396
* MAX_FIXED_DIGITS_AFTER_POINT</code><br/>
396397
* characters (one additional character for the sign, and one for the decimal point).
397398
*/
398-
public static void toFixed(double value, int requestedDigits, FormatOptions formatOptions, CharBuffer resultBuilder) {
399+
public static void toFixed(double value, int requestedDigits, FormatOptions formatOptions, Buffer resultBuilder) {
399400
// DOUBLE_CONVERSION_ASSERT(MAX_FIXED_DIGITS_BEFORE_POINT == 60);
400401

401402
if (Doubles.isSpecial(value)) {
@@ -442,7 +443,7 @@ public static void toFixed(double value, int requestedDigits, FormatOptions form
442443
* @param formatOptions
443444
* @throws IllegalArgumentException if <code>requestedDigits > MAX_EXPONENTIAL_DIGITS</code>
444445
*/
445-
public static void toExponential(double value, int requestedDigits, FormatOptions formatOptions, CharBuffer resultBuilder) {
446+
public static void toExponential(double value, int requestedDigits, FormatOptions formatOptions, Buffer resultBuilder) {
446447
if (Doubles.isSpecial(value)) {
447448
handleSpecialValues(value, formatOptions, resultBuilder);
448449
return;
@@ -512,7 +513,7 @@ public static void toExponential(double value, int requestedDigits, FormatOption
512513
* @throws IllegalArgumentException when <code>precision < MIN_PRECISION_DIGITS</code> or
513514
* <code>precision > MAX_PRECISION_DIGITS</code>
514515
*/
515-
public static void toPrecision(double value, int precision, FormatOptions formatOptions, CharBuffer resultBuilder) {
516+
public static void toPrecision(double value, int precision, FormatOptions formatOptions, Buffer resultBuilder) {
516517
if (Doubles.isSpecial(value)) {
517518
handleSpecialValues(value, formatOptions, resultBuilder);
518519
return;
@@ -562,7 +563,7 @@ public static void toPrecision(double value, int precision, FormatOptions format
562563
* @param formatOptions Additional options for this number's formatting.
563564
* @param resultBuilder The buffer to output to.
564565
*/
565-
public static void toHex(double value, int requestedDigits, FormatOptions formatOptions, CharBuffer resultBuilder) {
566+
public static void toHex(double value, int requestedDigits, FormatOptions formatOptions, Buffer resultBuilder) {
566567
if (Doubles.isSpecial(value)) {
567568
handleSpecialValues(value, formatOptions, resultBuilder);
568569
return;
@@ -651,7 +652,7 @@ private static boolean shouldEmitMinus(double value) {
651652
return (Double.doubleToRawLongBits(value) & Doubles.SIGN_MASK) != 0 && value != 0.0;
652653
}
653654

654-
private static void appendSign(double value, FormatOptions formatOptions, CharBuffer resultBuilder) {
655+
private static void appendSign(double value, FormatOptions formatOptions, Buffer resultBuilder) {
655656
if (shouldEmitMinus(value)) {
656657
resultBuilder.append('-');
657658
} else if (formatOptions.spaceWhenPositive()) {
@@ -771,7 +772,7 @@ static void doubleToAscii(double v, DtoaMode mode, int requestedDigits, DecimalR
771772
* Add character padding to the builder. If count is non-positive,
772773
* nothing is added to the builder.
773774
*/
774-
private static void addPadding(CharBuffer sb, char character, int count) {
775+
private static void addPadding(Buffer sb, char character, int count) {
775776
for (int i = count; i > 0; i--) sb.append(character);
776777
}
777778

src/main/java/org/squiddev/cobalt/Buffer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@
2424
*/
2525
package org.squiddev.cobalt;
2626

27-
import cc.tweaked.cobalt.internal.doubles.CharBuffer;
28-
2927
/**
3028
* String buffer for use in string library methods, optimized for producing {@link LuaString} instances.
3129
*
3230
* @see LuaValue
3331
* @see LuaString
3432
*/
35-
public final class Buffer implements CharBuffer {
33+
public final class Buffer {
3634
/**
3735
* Default capacity for a buffer: 64
3836
*/
@@ -181,7 +179,6 @@ public Buffer append(LuaString str, int start, int srcLength) {
181179
* @return {@code this}, for chaining.
182180
* @see LuaString#encode(String, byte[], int)
183181
*/
184-
@Override
185182
public Buffer append(String str) {
186183
final int n = str.length();
187184
ensure(n);

0 commit comments

Comments
 (0)