From 56909f091816a6b45dec667053dca9d7d25d9af4 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 6 Mar 2021 09:18:09 +0800 Subject: [PATCH] refactor --- src/util/_impl/_dedup_impl.scad | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/_impl/_dedup_impl.scad b/src/util/_impl/_dedup_impl.scad index 595b56df..7bef90da 100644 --- a/src/util/_impl/_dedup_impl.scad +++ b/src/util/_impl/_dedup_impl.scad @@ -13,10 +13,10 @@ function _dedup_add(buckets, i_elem, eq, hash, bucket_numbers) = b_idx = hash(elem) % bucket_numbers, bucket = buckets[b_idx] ) - len(bucket) == 0 ? concat(slice(buckets, 0, b_idx), [[i_elem]], slice(buckets, b_idx + 1)) : - some(bucket, function(i_e) eq(i_e[1], elem)) ? buckets : - concat( - slice(buckets, 0, b_idx), - [concat(bucket, [i_elem])], - slice(buckets, b_idx + 1) - ); \ No newline at end of file + some(bucket, function(i_e) eq(i_e[1], elem)) ? buckets : _add(buckets, bucket, i_elem, b_idx); + +function _add(buckets, bucket, i_elem, b_idx) = concat( + slice(buckets, 0, b_idx), + [concat(bucket, [i_elem])], + slice(buckets, b_idx + 1) +); \ No newline at end of file