matthiasblaesing commented on code in PR #9789:
URL: https://github.com/apache/netbeans/pull/9789#discussion_r4506310322


##########
profiler/profiler.heapwalker/src/org/netbeans/modules/profiler/heapwalk/details/basic/StringDetailsProvider.java:
##########
@@ -34,14 +34,18 @@
  */
 @ServiceProvider(service=DetailsProvider.class)
 public final class StringDetailsProvider extends DetailsProvider.Basic {
-    
+    // caching two fields
+    private int hiShift = -1;
+    private int loShift = -1;

Review Comment:
   Is this cache global or per heap? The code in the JPDA implementation 
indicates that the shifts are architecture dependent. So the shifts might by 
different when you change heaps.



##########
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();

Review Comment:
   ```suggestion
                       case 1 -> values.size() / 2; // UTF-16
                       default -> values.size();    // Latin1/ISO-8859-1
   ```



-- 
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

Reply via email to