pavpanchekha
2022-7-2 03:12:02

Is there a way to get non-generic versions of the hash set functions?


samth
2022-7-2 03:14:45

You mean “like set-add but without the overhead of generics”?


pavpanchekha
2022-7-2 03:14:46

I’ve got a tight loop that spends most of its time in set functions (the loop calls just set remove, set count, and set first)


samth
2022-7-2 03:14:57

If so, then the best solution is to use a hash table


pavpanchekha
2022-7-2 03:15:01

Got it


pavpanchekha
2022-7-2 03:15:12

Ok, I’ll custom write something


pavpanchekha
2022-7-2 03:15:33

I suspect a vector might be faster, but was hoping to get the speed for cheap


samth
2022-7-2 03:16:05

the hash table “implementation” is really easy


samth
2022-7-2 03:16:42

but calling set-first and set-remove repeatedly is probably the real problem


samth
2022-7-2 03:16:50

that is not going to be fast


pavpanchekha
2022-7-2 03:16:58

That’s why I think vector is better


pavpanchekha
2022-7-2 03:17:34

Sadly this one algorithm is 40% of run time so I kinda gotta actually go to town on it


pavpanchekha
2022-7-2 03:18:25

I’m thinking a vector with entries that can be set to #f. Then count, first, and remove can all be done in a single pass


samth
2022-7-2 03:18:25

but just using hash or set iteration is going to be much much better


pavpanchekha
2022-7-2 03:19:09

Iteration is faster than first?


pavpanchekha
2022-7-2 03:19:21

I only call first if it’s guaranteed to have one entry


pavpanchekha
2022-7-2 03:20:09

I’ll probably rewrite this because the overhead is pretty bad.


pavpanchekha
2022-7-2 03:20:46

(Overhead is something like 20% of the 40%, maybe more if tail calls are hiding something)


pavpanchekha
2022-7-2 03:21:23

By the way, what’s the fastest way to loop over a vector? Am I giving up speed if I use for instead of vector-for each?


hj93
2022-7-2 05:21:34

what makes lisp so great?