mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8287013: StringConcatFactory: remove short and byte mixers/prependers
Reviewed-by: jlaskey
This commit is contained in:
parent
828dc89ab8
commit
d5d19f52ce
2 changed files with 13 additions and 75 deletions
|
@ -68,17 +68,6 @@ final class StringConcatHelper {
|
|||
return checkOverflow(lengthCoder + (value ? 4 : 5));
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix value length and coder into current length and coder.
|
||||
* @param lengthCoder String length with coder packed into higher bits
|
||||
* the upper word.
|
||||
* @param value value to mix in
|
||||
* @return new length and coder
|
||||
*/
|
||||
static long mix(long lengthCoder, byte value) {
|
||||
return mix(lengthCoder, (int)value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix value length and coder into current length and coder.
|
||||
* @param lengthCoder String length with coder packed into higher bits
|
||||
|
@ -90,17 +79,6 @@ final class StringConcatHelper {
|
|||
return checkOverflow(lengthCoder + 1) | (StringLatin1.canEncode(value) ? 0 : UTF16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix value length and coder into current length and coder.
|
||||
* @param lengthCoder String length with coder packed into higher bits
|
||||
* the upper word.
|
||||
* @param value value to mix in
|
||||
* @return new length and coder
|
||||
*/
|
||||
static long mix(long lengthCoder, short value) {
|
||||
return mix(lengthCoder, (int)value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix value length and coder into current length and coder.
|
||||
* @param lengthCoder String length with coder packed into higher bits
|
||||
|
@ -198,23 +176,6 @@ final class StringConcatHelper {
|
|||
return indexCoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends constant and the stringly representation of value into buffer,
|
||||
* given the coder and final index. Index is measured in chars, not in bytes!
|
||||
*
|
||||
* @param indexCoder final char index in the buffer, along with coder packed
|
||||
* into higher bits.
|
||||
* @param buf buffer to append to
|
||||
* @param value boolean value to encode
|
||||
* @param prefix a constant to prepend before value
|
||||
* @return updated index (coder value retained)
|
||||
*/
|
||||
static long prepend(long indexCoder, byte[] buf, byte value, String prefix) {
|
||||
indexCoder = prepend(indexCoder, buf, (int)value);
|
||||
if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix);
|
||||
return indexCoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends the stringly representation of char value into buffer,
|
||||
* given the coder and final index. Index is measured in chars, not in bytes!
|
||||
|
@ -251,23 +212,6 @@ final class StringConcatHelper {
|
|||
return indexCoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends constant and the stringly representation of value into buffer,
|
||||
* given the coder and final index. Index is measured in chars, not in bytes!
|
||||
*
|
||||
* @param indexCoder final char index in the buffer, along with coder packed
|
||||
* into higher bits.
|
||||
* @param buf buffer to append to
|
||||
* @param value boolean value to encode
|
||||
* @param prefix a constant to prepend before value
|
||||
* @return updated index (coder value retained)
|
||||
*/
|
||||
static long prepend(long indexCoder, byte[] buf, short value, String prefix) {
|
||||
indexCoder = prepend(indexCoder, buf, (int)value);
|
||||
if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix);
|
||||
return indexCoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepends the stringly representation of integer value into buffer,
|
||||
* given the coder and final index. Index is measured in chars, not in bytes!
|
||||
|
|
|
@ -496,7 +496,19 @@ public final class StringConcatFactory {
|
|||
Class<?>[] ptypes = mt.erase().parameterArray();
|
||||
MethodHandle[] filters = null;
|
||||
for (int i = 0; i < ptypes.length; i++) {
|
||||
MethodHandle filter = stringifierFor(ptypes[i]);
|
||||
Class<?> cl = ptypes[i];
|
||||
MethodHandle filter = null;
|
||||
if (cl == byte.class || cl == short.class) {
|
||||
// use int for subword integral types; still need special mixers
|
||||
// and prependers for char, boolean
|
||||
ptypes[i] = int.class;
|
||||
} else if (cl == Object.class) {
|
||||
filter = objectStringifier();
|
||||
} else if (cl == float.class) {
|
||||
filter = floatStringifier();
|
||||
} else if (cl == double.class) {
|
||||
filter = doubleStringifier();
|
||||
}
|
||||
if (filter != null) {
|
||||
if (filters == null) {
|
||||
filters = new MethodHandle[ptypes.length];
|
||||
|
@ -825,24 +837,6 @@ public final class StringConcatFactory {
|
|||
MIXERS = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stringifier for references and floats/doubles only.
|
||||
* Always returns null for other primitives.
|
||||
*
|
||||
* @param t class to stringify
|
||||
* @return stringifier; null, if not available
|
||||
*/
|
||||
private static MethodHandle stringifierFor(Class<?> t) {
|
||||
if (t == Object.class) {
|
||||
return objectStringifier();
|
||||
} else if (t == float.class) {
|
||||
return floatStringifier();
|
||||
} else if (t == double.class) {
|
||||
return doubleStringifier();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static MethodHandle lookupStatic(Lookup lookup, Class<?> refc, String name,
|
||||
Class<?> rtype, Class<?>... ptypes) {
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue