nfsantos commented on code in PR #1511: URL: https://github.com/apache/jackrabbit-oak/pull/1511#discussion_r1632869189
########## oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/json/JsopBuilder.java: ########## @@ -275,6 +278,34 @@ public static String encode(String s) { return '\"' + s + '\"'; } + /** + * Similar to #encode(String) but appends the result to the given buffer. This method exists to avoid the allocation + * of intermediate objects to represent the encoded String when the caller already has a buffer where the result + * should be appended. + * + * @param s the text to convert + * @param buff the target buffer + * @return the target buffer with the encoded string appended + */ + private static StringBuilder encode(String s, StringBuilder buff) { + if (s == null) { + return buff.append("null"); + } + int length = s.length(); + if (length == 0) { + return buff.append("\"\""); Review Comment: As this method is a variation of `StringBuilder encode(String s)`, I kept it as close as possible to the other method with only the changes needed to use an existing `StringBuilder`, without doing any stylist changes, as this seems to be outside the scope of this PR. -- 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: dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org