jtulach commented on code in PR #9789:
URL: https://github.com/apache/netbeans/pull/9789#discussion_r4521527045
##########
profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/details/basic/StringDetailsProvider.java:
##########
@@ -62,36 +66,53 @@ public String getDetailsString(String className, Instance
instance, Heap heap) {
0, count, null,
"..."); // NOI18N
} else {
- return getJDK9String(heap, instance, "value", coder, null,
"..."); // NOI18N
+ return getJDK9String(heap, instance, "value", coder, null,
"..."); // NOI18N
}
}
return null;
}
+ @Override
public View getDetailsView(String className, Instance instance, Heap heap)
{
return new ArrayValueView(className, instance, heap);
}
private String getJDK9String(Heap heap, Instance instance, String field,
byte coder, String separator, String trailer) {
Object byteArray = instance.getValueOfField(field);
if (byteArray instanceof PrimitiveArrayInstance) {
+ hiShift = -1;
+ loShift = -1;
List<String> values = ((PrimitiveArrayInstance)
byteArray).getValues();
if (values != null) {
- StringDecoder decoder = new StringDecoder(heap, coder, values);
- int valuesCount = decoder.getStringLength();
+ int valuesCount = switch (coder) {
+ case 1 -> values.size() / 2;
+ default -> values.size();
+ };
int separatorLength = separator == null ? 0 :
separator.length();
int trailerLength = trailer == null ? 0 : trailer.length();
int estimatedSize = Math.min(valuesCount * (1 +
separatorLength), DetailsUtils.MAX_ARRAY_LENGTH + trailerLength);
StringBuilder value = new StringBuilder(estimatedSize);
int lastValue = valuesCount - 1;
for (int i = 0; i <= lastValue; i++) {
- value.append(decoder.getValueAt(i));
if (value.length() >= DetailsUtils.MAX_ARRAY_LENGTH) {
if (trailerLength > 0) {
value.append(trailer);
}
break;
}
+ value.append(switch (coder) {
Review Comment:
Reusing `StringDecoder` since ba9f3be1db3a however...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists