Skip to content

Commit

Permalink
[std] Clarify StringBuf.clear documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Frixuu committed Dec 4, 2024
1 parent b8a30cb commit eb20fac
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions std/StringBuf.hx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ class StringBuf {
}

/**
Removes all characters from `this` StringBuf, making it possible to reuse it.
Visibly removes all characters from `this` StringBuf, making it possible to reuse it.
It will always allocate less memory than constructing a new `StringBuf` instance.
Implementation detail: On some targets, where `this` StringBuf manages an internal buffer,
that buffer MAY not be reallocated on `clear`, preserving its capacity.
This is done to avoid unnecessary allocations on later `add` operations,
but might be incorrectly perceived as a memory leak.
**/
public inline function clear():Void {
b = "";
Expand Down

0 comments on commit eb20fac

Please sign in to comment.