Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dict.has & improve Dict helpers performance #7316

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DZakh
Copy link
Contributor

@DZakh DZakh commented Feb 25, 2025

No description provided.

@@ -29,7 +29,7 @@ let forEach = (dict, f) => {
}

let forEachWithKey = (dict, f) => {
dict->toArray->Stdlib_Array.forEach(((key, value)) => f(value, key))
dict->keysToArray->Stdlib_Array.forEach(key => f(dict->getUnsafe(key), key))
Comment on lines +18 to +19
Object.keys(dict).forEach(key => {
let value = dict[key];
Copy link
Contributor Author

@DZakh
Copy link
Contributor Author

DZakh commented Feb 25, 2025

Ready for review

Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

Great! Thanks a lot!

target[key] = f(value);
});
return target;
}

let has = ((dict, key) => key in dict);
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't we want to use hasOwnProperty there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants