MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / memoize

Function memoize

lib/utils.h:450–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448 // Thread-unsafe memoization
449 template<class F, class R=decltype(std::declval<F>()())>
450 static inline std::function<R()> memoize(F f)
451 {
452 bool init = false;
453 R result{};
454 return [=]() mutable -> R {
455 if (init)
456 return result;
457 result = f();
458 init = true;
459 return result;
460 };
461 }
462}
463
464#endif

Callers 2

findVariableChangedFunction · 0.85
memoizeMethod · 0.85

Calls 1

fFunction · 0.50

Tested by 1

memoizeMethod · 0.68