Skip to content

Commit 2cdb0e2

Browse files
committed
improve: StringBuilder initialization
Add detailed documentation for size_hint parameter
1 parent d520076 commit 2cdb0e2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

builtin/stringbuilder_buffer.mbt

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ struct StringBuilder {
1919
}
2020

2121
///|
22+
/// Creates a new string builder with an optional initial capacity hint.
23+
///
24+
/// Parameters:
25+
///
26+
/// * `size_hint` : An optional initial capacity hint for the internal buffer. If
27+
/// less than 1, a minimum capacity of 1 is used. Defaults to 0. It is the size of bytes,
28+
/// not the size of characters. `size_hint` may be ignored on some platforms, JS for example.
29+
///
30+
/// Returns a new `StringBuilder` instance with the specified initial capacity.
31+
///
2232
pub fn StringBuilder::new(size_hint~ : Int = 0) -> StringBuilder {
2333
let initial = if size_hint < 1 { 1 } else { size_hint }
24-
let data = FixedArray::make(initial, Byte::default())
34+
let data : FixedArray[Byte] = FixedArray::make(initial, 0)
2535
{ data, len: 0 }
2636
}
2737

0 commit comments

Comments
 (0)