simplify str_starts_with

This commit is contained in:
Folkert 2020-12-03 16:10:24 +01:00
parent 770d4d7bc3
commit f21af47fc1
2 changed files with 14 additions and 76 deletions

View file

@ -576,7 +576,13 @@ test "countGraphemeClusters: emojis, ut8, and ascii characters" {
// Str.startsWith
pub fn startsWith(bytes_ptr: [*]u8, bytes_len: usize, prefix_ptr: [*]u8, prefix_len: usize) callconv(.C) bool {
pub fn startsWith(string: RocStr, prefix: RocStr) callconv(.C) bool {
const bytes_len = string.len();
const bytes_ptr = string.as_u8_ptr();
const prefix_len = prefix.len();
const prefix_ptr = prefix.as_u8_ptr();
if (prefix_len > bytes_len) {
return false;
}