EgorBaranovEnjoysTyping commented on code in PR #13262:
URL: https://github.com/apache/ignite/pull/13262#discussion_r3481860158


##########
modules/commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java:
##########
@@ -1713,92 +1271,37 @@ public static String toString(String str, Object... 
triplets) {
 
             propSens[i] = (Boolean)sens;
         }
-
-        SBLimitedLength sb = threadLocSB.get();
-
-        boolean newStr = sb.length() == 0;
-
-        try {
-            return toStringImpl(str, sb, propNames, propVals, propSens, 
propCnt);
-        }
-        finally {
-            if (newStr)
-                sb.reset();
-        }
+        return toStringImpl(str, propNames, propVals, propSens, propCnt);
     }
 
     /**
      * Creates an uniformed string presentation for the binary-like object.
      *
      * @param str Output prefix or {@code null} if empty.
-     * @param buf String builder buffer.
      * @param propNames Names of object properties.
      * @param propVals Property values.
      * @param propSens Sensitive flag of values or {@code null} if all values 
is not sensitive.
      * @param propCnt Properties count.
      * @return String presentation of the object.
      */
-    private static String toStringImpl(String str, SBLimitedLength buf, 
Object[] propNames, Object[] propVals,
+    private static String toStringImpl(String str, Object[] propNames, 
Object[] propVals,
         boolean[] propSens, int propCnt) {
-
-        boolean newStr = buf.length() == 0;
-
-        if (str != null)
-            buf.a(str).a(" ");
-
-        buf.a("[");
-
-        appendVals(buf, true, propNames, propVals, propSens, propCnt);
-
-        buf.a(']');
-
-        if (newStr)
-            return buf.toString();
-
-        // Called from another GTSB.toString(), so this string is already in 
the buffer and shouldn't be returned.
-        return "";
-    }
-
-    /**
-     * Append additional values to the buffer.
-     *
-     * @param buf Buffer.
-     * @param first First value flag.
-     * @param addNames Names of additional values to be included.
-     * @param addVals Additional values to be included.
-     * @param addSens Sensitive flag of values or {@code null} if all values 
are not sensitive.
-     * @param addLen How many additional values will be included.
-     */
-    private static void appendVals(SBLimitedLength buf,
-        boolean first,
-        Object[] addNames,
-        Object[] addVals,
-        boolean[] addSens,
-        int addLen
-    ) {
-        if (addLen > 0) {
-            for (int i = 0; i < addLen; i++) {
-                Object addVal = addVals[i];
-
-                if (addVal != null) {
-                    if (addSens != null && addSens[i] && !includeSensitive())
-                        continue;
-
-                    GridToStringInclude incAnn = 
addVal.getClass().getAnnotation(GridToStringInclude.class);
-
-                    if (incAnn != null && incAnn.sensitive() && 
!includeSensitive())
-                        continue;
-                }
-
-                if (!first)
-                    buf.a(", ");
-                else
-                    first = false;
-
-                buf.a(addNames[i]).a('=');
-
-                toString(buf, addVal);
-            }
+        boolean isNew = GridToStringNode.init();
+        try {
+            List<GridToStringNode> addNodes =
+                    GridToStringNodeFactory.getNodes(propNames, propVals, 
propSens, propCnt);
+            GridToStringNode node = GridToStringNode.getRootNode(str, 
addNodes);
+            return isNew ? node.toString() : 
GridToStringNode.appendInnerBuffer(node);

Review Comment:
   It called once in code and it's the same way as previous. There're some 
calls to this method that depends on empty string returned. 



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

Reply via email to