summaryrefslogtreecommitdiff
path: root/src/Normalize.zig
diff options
context:
space:
mode:
authorGravatar Jose Colon Rodriguez2024-04-02 13:22:37 -0400
committerGravatar Jose Colon Rodriguez2024-04-02 13:22:37 -0400
commitcc8d110f834d112a230024122fddfcc6e0a67759 (patch)
treea69b7ef8fa81f82b9ce9a16ce489b696d237e284 /src/Normalize.zig
parentUpdated README with zig fetch (diff)
downloadzg-cc8d110f834d112a230024122fddfcc6e0a67759.tar.gz
zg-cc8d110f834d112a230024122fddfcc6e0a67759.tar.xz
zg-cc8d110f834d112a230024122fddfcc6e0a67759.zip
NormData init now takes pointer to uninitialized Self to avoid stack copy issues.
Diffstat (limited to '')
-rw-r--r--src/Normalize.zig24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/Normalize.zig b/src/Normalize.zig
index 85e3aa3..f2dbb3e 100644
--- a/src/Normalize.zig
+++ b/src/Normalize.zig
@@ -175,7 +175,8 @@ fn decompose(
175 175
176test "decompose" { 176test "decompose" {
177 const allocator = testing.allocator; 177 const allocator = testing.allocator;
178 const data = try NormData.init(allocator); 178 var data: NormData = undefined;
179 try NormData.init(&data, allocator);
179 defer data.deinit(); 180 defer data.deinit();
180 var n = Self{ .norm_data = &data }; 181 var n = Self{ .norm_data = &data };
181 182
@@ -295,7 +296,8 @@ fn nfxd(self: Self, allocator: mem.Allocator, str: []const u8, form: Form) !Resu
295 296
296test "nfd ASCII / no-alloc" { 297test "nfd ASCII / no-alloc" {
297 const allocator = testing.allocator; 298 const allocator = testing.allocator;
298 const data = try NormData.init(allocator); 299 var data: NormData = undefined;
300 try NormData.init(&data, allocator);
299 defer data.deinit(); 301 defer data.deinit();
300 const n = Self{ .norm_data = &data }; 302 const n = Self{ .norm_data = &data };
301 303
@@ -307,7 +309,8 @@ test "nfd ASCII / no-alloc" {
307 309
308test "nfd !ASCII / alloc" { 310test "nfd !ASCII / alloc" {
309 const allocator = testing.allocator; 311 const allocator = testing.allocator;
310 const data = try NormData.init(allocator); 312 var data: NormData = undefined;
313 try NormData.init(&data, allocator);
311 defer data.deinit(); 314 defer data.deinit();
312 const n = Self{ .norm_data = &data }; 315 const n = Self{ .norm_data = &data };
313 316
@@ -319,7 +322,8 @@ test "nfd !ASCII / alloc" {
319 322
320test "nfkd ASCII / no-alloc" { 323test "nfkd ASCII / no-alloc" {
321 const allocator = testing.allocator; 324 const allocator = testing.allocator;
322 const data = try NormData.init(allocator); 325 var data: NormData = undefined;
326 try NormData.init(&data, allocator);
323 defer data.deinit(); 327 defer data.deinit();
324 const n = Self{ .norm_data = &data }; 328 const n = Self{ .norm_data = &data };
325 329
@@ -331,7 +335,8 @@ test "nfkd ASCII / no-alloc" {
331 335
332test "nfkd !ASCII / alloc" { 336test "nfkd !ASCII / alloc" {
333 const allocator = testing.allocator; 337 const allocator = testing.allocator;
334 const data = try NormData.init(allocator); 338 var data: NormData = undefined;
339 try NormData.init(&data, allocator);
335 defer data.deinit(); 340 defer data.deinit();
336 const n = Self{ .norm_data = &data }; 341 const n = Self{ .norm_data = &data };
337 342
@@ -530,7 +535,8 @@ fn nfxc(self: Self, allocator: mem.Allocator, str: []const u8, form: Form) !Resu
530 535
531test "nfc" { 536test "nfc" {
532 const allocator = testing.allocator; 537 const allocator = testing.allocator;
533 const data = try NormData.init(allocator); 538 var data: NormData = undefined;
539 try NormData.init(&data, allocator);
534 defer data.deinit(); 540 defer data.deinit();
535 const n = Self{ .norm_data = &data }; 541 const n = Self{ .norm_data = &data };
536 542
@@ -542,7 +548,8 @@ test "nfc" {
542 548
543test "nfkc" { 549test "nfkc" {
544 const allocator = testing.allocator; 550 const allocator = testing.allocator;
545 const data = try NormData.init(allocator); 551 var data: NormData = undefined;
552 try NormData.init(&data, allocator);
546 defer data.deinit(); 553 defer data.deinit();
547 const n = Self{ .norm_data = &data }; 554 const n = Self{ .norm_data = &data };
548 555
@@ -564,7 +571,8 @@ pub fn eql(self: Self, allocator: mem.Allocator, a: []const u8, b: []const u8) !
564 571
565test "eql" { 572test "eql" {
566 const allocator = testing.allocator; 573 const allocator = testing.allocator;
567 const data = try NormData.init(allocator); 574 var data: NormData = undefined;
575 try NormData.init(&data, allocator);
568 defer data.deinit(); 576 defer data.deinit();
569 const n = Self{ .norm_data = &data }; 577 const n = Self{ .norm_data = &data };
570 578