Skip to content

Conversation

@barunio
Copy link
Contributor

@barunio barunio commented Jan 10, 2019

From the relevant commit:

Previously, calling memoize with the same method name more than once would
result in a perpetual loop when calling that method. This commit fixes the bug.
Memoizer now keeps track of which methods have been memoized and avoids trying
to memoize an already-memoized method.

Copy link

@tristil tristil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍰

@bryan-ash bryan-ash self-assigned this Jan 10, 2019
Copy link
Contributor

@bryan-ash bryan-ash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍖 🏅

barunio and others added 3 commits February 22, 2022 16:19
Previously, calling `memoize` with the same method name more than once would
result in a perpetual loop when calling that method. This commit fixes the bug.
Memoizer now keeps track of which methods have been memoized and avoids trying
to memoize an already-memoized method.
This commit changes the implementation of the
`memoizer_memoized_methods` variable to use a hash instead of an array
so that the lookup is constant time.
Only the patch version has been bumped. Changes since the previous
version should be backwards-compatible with all tested versions of ruby.

Co-authored-by: Nathan Fixler <nathan.fixler@appfolio.com>
@fixlr fixlr force-pushed the fix_double_memoization_bug branch from 5bee81b to de5ccae Compare February 23, 2022 00:26
@megatux
Copy link

megatux commented May 20, 2022

Why is this stuck?

@tristil
Copy link

tristil commented May 23, 2022

@fixlr can you see this?

@fmichaut-diff
Copy link

fmichaut-diff commented Mar 14, 2023

Merging this would also allow for improving the unmemoize_all method. It is currently iterating over all the methods of the class, converting the names to strings, and matching against a regex for every call.

Now that we have an array of memoized methods (@memoizer_memoized_methods.keys), we could simply iterate over it

AlexWayfer added a commit to AlexWayfer/alt_memery that referenced this pull request Mar 14, 2023
@AlexWayfer
Copy link

JFYI, I've added similar spec to my alt_memery gem and got no fails. You're free to use and I'd glad to see feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants