comphead commented on code in PR #4885:
URL: https://github.com/apache/datafusion-comet/pull/4885#discussion_r3560502442


##########
native/spark-expr/src/string_funcs/base64.rs:
##########
@@ -83,12 +115,19 @@ fn encode(bytes: &[u8], chunk: bool) -> String {
 /// offsets and character offsets coincide. Takes the string by value so the 
common short-input
 /// case (no wrapping needed) returns it without a second allocation.
 fn chunk_into_lines(encoded: String) -> String {
-    const LINE_LEN: usize = 76;
     if encoded.len() <= LINE_LEN {
         return encoded;
     }
+    let mut out = String::new();
+    chunk_into_lines_buf(&encoded, &mut out);
+    out
+}
+
+/// Append the CRLF-wrapped form of `encoded` (lines of at most 76 characters) 
into `out`.
+/// The caller is expected to have cleared `out`; only used when 
`encoded.len() > LINE_LEN`.
+fn chunk_into_lines_buf(encoded: &str, out: &mut String) {
     let separators = (encoded.len() - 1) / LINE_LEN;
-    let mut out = String::with_capacity(encoded.len() + separators * 2);
+    out.reserve(encoded.len() + separators * 2);

Review Comment:
   should we reserve every row? perhaps we can do a reusable buffer?



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

Reply via email to