mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
simplify str_count_graphemes
This commit is contained in:
parent
3d6ea21184
commit
770d4d7bc3
2 changed files with 9 additions and 20 deletions
|
@ -495,7 +495,10 @@ test "countSegments: delimiter interspered" {
|
|||
// Str.countGraphemeClusters
|
||||
const grapheme = @import("helpers/grapheme.zig");
|
||||
|
||||
pub fn countGraphemeClusters(bytes_ptr: [*]u8, bytes_len: usize) callconv(.C) usize {
|
||||
pub fn countGraphemeClusters(string: RocStr) callconv(.C) usize {
|
||||
const bytes_len = string.len();
|
||||
const bytes_ptr = string.as_u8_ptr();
|
||||
|
||||
var bytes = bytes_ptr[0..bytes_len];
|
||||
var iter = (unicode.Utf8View.init(bytes) catch unreachable).iterator();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue