(s: &str, count: i64, max_size: usize)
| 163 | /// Computes repeat for a single string value with max size check |
| 164 | #[inline] |
| 165 | fn compute_repeat(s: &str, count: i64, max_size: usize) -> Result<String> { |
| 166 | if count <= 0 { |
| 167 | return Ok(String::new()); |
| 168 | } |
| 169 | let result_len = s.len().saturating_mul(count as usize); |
| 170 | if result_len > max_size { |
| 171 | return exec_err!( |
| 172 | "string size overflow on repeat, max size is {}, but got {}", |
| 173 | max_size, |
| 174 | result_len |
| 175 | ); |
| 176 | } |
| 177 | Ok(s.repeat(count as usize)) |
| 178 | } |
| 179 | |
| 180 | /// Repeats string the specified number of times. |
| 181 | /// repeat('Pg', 4) = 'PgPgPgPg' |
no test coverage detected
searching dependent graphs…