zeek / spicy

C++ parser generator for dissecting protocols & files.
https://docs.zeek.org/projects/spicy
Other
246 stars 35 forks source link

Remove use of `std::function` #1736

Closed rsmmr closed 4 months ago

rsmmr commented 4 months ago

This removes all usage of std::function, and all includes of the corresponding functional header. That is large header that tends to introduce quite a bit of overhead, and we don't actually need it: all of our uses of std::function are easy to replace with other mechanisms: often just raw pointers, sometimes template parameters.

This also includes some further cleanup of code no longer needed.

rsmmr commented 4 months ago

This looks fine to me, but I wonder whether it actually improves compile time, either for analyzers or Spicy itself since it touches both the runtime lib (filters, sinks, parse fcts) and Spicy itself; I'd expect some of the work to instantiate std::function would also be needed for lambdas.

Honestly I don't know either but I've been reading quite a bit about std::function and sheer size of the <functional> header for a while now, so I just went ahead because it doesn't look like we actually need it.

I had a quick look at the list of clang-tidy checks but didn't see anything we could configure to automatically reject uses of std::function in the future.

I'll keep an eye on it. :-)