Skip to content

Commit d884851

Browse files
committed
Use std::bit_ceil() to calculate new string size
1 parent 5ffff8d commit d884851

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎src/scratch/string_functions.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ extern "C"
2121
size++; // null terminator
2222

2323
if (str->allocatedSize < size) {
24-
// TODO: Use std::bit_ceil() in C++20
25-
const size_t newSize = std::pow(2, std::ceil(std::log2(size)));
24+
const size_t newSize = std::bit_ceil(size);
2625
assert((str->data && str->allocatedSize > 0) || (!str->data && str->allocatedSize == 0));
2726

2827
if (str->data)

0 commit comments

Comments
 (0)