Skip to content

Commit

Permalink
std::strings: fix join function
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Apr 23, 2024
1 parent 3b5a0c4 commit 17ee8d3
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions std/strings/strings.jule
Original file line number Diff line number Diff line change
Expand Up @@ -459,23 +459,9 @@ pub fn join(parts: []str, sep: str): str {
| 0:
ret ""
| 1:
ret parts[1]
ret parts[0]
}
let mut n = 0
if sep.len > 0 {
if sep.len >= int.MAX/(parts.len-1) {
panic("std::strings: join: output length overflow")
}
n += sep.len * (parts.len - 1)
}
for _, part in parts {
if part.len > int.MAX-n {
panic("std::strings: join: output length overflow")
}
n += part.len
}
let mut s = make(str, n)
s += parts[0]
let mut s = parts[0]
for _, part in parts[1:] {
s += sep
s += part
Expand Down

0 comments on commit 17ee8d3

Please sign in to comment.