On Sun, Jul 23, 2017 at 8:43 PM, David Storrs <david.sto...@gmail.com> wrote: > > > On Sun, Jul 23, 2017 at 8:05 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: >> - Use a struct instead of a hash to represent a split. > > > Oh, are structs faster than hashes?
Can't make a blanket statement, and the best reason to use a struct in this case has nothing to do with performance; it's simply that the code wants an associative data structure with a set of labels (keys) that are known in advance. The keys aren't really data in this case. Anyhow, on the matter of performance: First, there's no hashing involved in struct lookup (which is just an indexed load) or update. That's already a point in the struct's favor. Struct update does, however, involve a full copy, so overall performance will depend on just how much data needs to be copied. In this case, the structs/hashes have only four keys/labels. And immutable hashes have a more complex representation and a larger constant-time overhead. So, I would expect structs to perform better here, but I doubt that the difference is a big deal. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.