[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
a C<->guile O(2N) problem
From: |
Christopher Lam |
Subject: |
a C<->guile O(2N) problem |
Date: |
Sun, 8 Dec 2019 13:15:25 +0000 |
Hello guilers
I am asking for some help optimizing C<->guile while working on the
simplest of lispy data structures; the proper list. The C equivalent being
used is glib's g_list.
In https://github.com/Gnucash/gnucash/blob/maint/common/base-typemaps.i#L142
these are converted via the simple but O(2*N) expensive
prepend-and-reverse, building SCM list by traversing g_list, and vice versa
for the return trip.
It came to light that if we could define the GList transform with CAR =
node->data and CDR = node->next; the C->SCM transform could be O(1)
efficient. There are issues about finding the correct SWIG converter for
node->data pointer dereferences, but this is a problem for another day.
With SCM->C transform, we don't anticipate long lists, so, the issue is
less acute, but it would be nice to optimise it too.
Does anyone have experience converting the above efficiently? Is this
something that would need ffi work?
Thanks for any help!
- a C<->guile O(2N) problem,
Christopher Lam <=