Skip to content

Commit

Permalink
std::strings: minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 6, 2024
1 parent 400a428 commit d00878c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions std/strings/strings.jule
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ fn Replace(s: str, sub: str, new: str, mut n: int): str {
n = m
}

mut ss := StrBuilder.New(len(s) + n * (len(new) - len(sub)))
mut ss := StrBuilder.New((len(s) + n * (len(new) - len(sub))) + 1)
mut i := 0
for n > 0; n-- {
j := FindAt(s, sub, i)
Expand Down Expand Up @@ -437,7 +437,7 @@ fn Join(parts: []str, sep: str): str {
n += len(part)
n++
}
mut s := StrBuilder.New(n)
mut s := StrBuilder.New(n + 1)
s.WriteStr(parts[0])
for _, part in parts[1:] {
s.WriteStr(sep)
Expand Down

0 comments on commit d00878c

Please sign in to comment.