hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit e0c55f90741758207b580df22d776af6976f3a70
parent 568fe624fc236a2cc0f97f0a501ab4d77e66c9b1
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Fri, 18 Feb 2022 12:47:57 +0100

use strings::{dupall,freeall} on hare::ast::ident

Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>

Diffstat:
Mhare/ast/ident.ha | 15++-------------
1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/hare/ast/ident.ha b/hare/ast/ident.ha @@ -10,12 +10,7 @@ export type ident = []str; export def IDENT_MAX: size = 255; // Frees resources associated with an [[ident]]ifier. -export fn ident_free(ident: ident) void = { - for (let i = 0z; i < len(ident); i += 1) { - free(ident[i]); - }; - free(ident); -}; +export fn ident_free(ident: ident) void = strings::freeall(ident); // Returns true if two [[ident]]s are identical. export fn ident_eq(a: ident, b: ident) bool = { @@ -31,10 +26,4 @@ export fn ident_eq(a: ident, b: ident) bool = { }; // Duplicates an [[ident]]. -export fn ident_dup(id: ident) ident = { - let new: ident = alloc([], len(id)); - for (let i = 0z; i < len(id); i += 1) { - append(new, strings::dup(id[0])); - }; - return new; -}; +export fn ident_dup(id: ident) ident = strings::dupall(id);