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

Tidy up HashMap and MultiMap #864

Closed
wants to merge 1 commit into from
Closed

Conversation

fumieval
Copy link
Contributor

Removed a lot of unnecessary strict bindings

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@kazu-yamamoto
Copy link
Contributor

@fumieval Just a confirmation. Do you notice that warp.cabal has Strict and StrictData?

@fumieval
Copy link
Contributor Author

No, but that shouldn't matter for this change

!h = hash path
!mm' = I.insertWith (<>) h [(path,v)] mm
insert path v (MultiMap mm) = MultiMap
$ I.insertWith (flip (<>)) (hash path) [(path,v)] mm
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why flip is introduced here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

insertWith (++) is quadratic because it appends an element to a list. Does anything depend on the order of inner lists?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok, I misunderstood then

[] -> go kss acc
_ -> go kss ((h,rs) : acc)
pruneWith (MultiMap mm) action = I.foldrWithKey
(\h s cont acc -> do
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to change this function to a local function after where.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you explain why? Is it a style preference or does it produce a better core?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a style preference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

Removed a lot of unnecessary strict bindings
@kazu-yamamoto
Copy link
Contributor

I run CI again.

@kazu-yamamoto
Copy link
Contributor

We should understand whether or not the following failure on Windows is due to this PR:

warp                > 
warp                >   test\RunSpec.hs:322:9: 
warp                >   1) Run, chunked bodies, in chunks
warp                >        uncaught exception: IOException of type InvalidArgument
warp                >        Network.Socket.sendBuf: invalid argument (Invalid argument)
warp                > 
warp                >   To rerun use: --match "/Run/chunked bodies/in chunks/"
warp                > 
warp                > Randomized with seed 1880375916
warp                > 
warp                > Finished in 7.9339 seconds
warp                > 96 examples, 1 failure
warp                > Test suite spec failed

@kazu-yamamoto
Copy link
Contributor

I run CI once more and it succeeded. Let's merge.

Copy link
Contributor

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

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

Now LGTM.

kazu-yamamoto added a commit to kazu-yamamoto/wai that referenced this pull request Nov 11, 2021
@kazu-yamamoto
Copy link
Contributor

Rebased and merged. Thank you for your contribution!

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.

None yet

2 participants