commit f7608c39b3ec27bc33406893d05f5b78a8b003ce
parent 7ff4dde820c04056022d05e37aac34b30a89ce56
Author: Bor Grošelj Simić <bgs@turminal.net>
Date: Tue, 2 May 2023 04:27:05 +0200
datetime::new: use slice copy instead of loop
Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
Diffstat:
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/datetime/datetime.ha b/datetime/datetime.ha
@@ -141,13 +141,9 @@ export fn new(
0, 0, 0, 0, // hour min sec nsec
];
- if (len(fields) > len(_fields)) {
- abort("datetime::new(): Too many field arguments");
- };
-
- for (let i = 0z; i < len(fields); i += 1) {
- _fields[i] = fields[i];
- };
+ assert(len(fields) <= len(_fields),
+ "datetime::new(): Too many field arguments");
+ _fields[..len(fields)] = fields;
const year = _fields[0];
const month = _fields[1];