Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Conversation

@no-longer-on-githu-b
Copy link
Contributor

Seems to have been fixed several times before, but somehow still slipped through.

Uses the same check record updates use now.

var r = {};
for (var k in m) {
if (m.hasOwnProperty(k)) {
if ({}.hasOwnProperty.call(m, k)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we make a variable for {} and reuse it throughout please? {} does actually go through the process of constructing a new object every time, so if in heavily called code the overhead can be noticeable.

Copy link
Contributor Author

@no-longer-on-githu-b no-longer-on-githu-b Jan 25, 2017

Choose a reason for hiding this comment

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

var hasOwnProperty = {}.hasOwnProperty; would also cache the lookup of the method. 👌🏻


// module Data.StrMap

var hasOwnProperty = {}.hasOwnProperty;

Choose a reason for hiding this comment

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

You can just delete this line. The global object already has this binding for you.

var r = {};
for (var k in m) {
if (m.hasOwnProperty(k)) {
if (hasOwnProperty(m, k)) {

Choose a reason for hiding this comment

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

You forgot .call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_copy isn't being used at all. Let's delete it.

@garyb
Copy link
Member

garyb commented Jan 25, 2017

Looks good to me now if @michaelficarra is also happy?

@paf31 any objections? I'm not really sure why previous attempts at this weren't accepted 😄

b <- arbitrary
k <- arbitrary
kIshasOwnProperty <- (&&) <$> arbitrary <*> arbitrary
k <- if kIshasOwnProperty then pure "hasOwnProperty" else arbitrary
Copy link
Contributor

Choose a reason for hiding this comment

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

Might frequency be a more idiomatic way of saying that we should occasionally use 'hasOwnProperty' as a key? https://pursuit.purescript.org/packages/purescript-quickcheck/3.1.1/docs/Test.QuickCheck.Gen#v:frequency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya! Didn't know about that one, will add. 👍

Copy link

@michaelficarra michaelficarra left a comment

Choose a reason for hiding this comment

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

LGTM after frequency is used.

@paf31
Copy link
Contributor

paf31 commented Jan 25, 2017

Looks good to me. I just wanted to avoid the approach where we mangled keys, since StrMap needs to continue to be usable as an FFI structure.

Thanks @rightfold!

@garyb garyb merged commit e13b408 into purescript-deprecated:master Jan 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants