Skip to content

Commit

Permalink
Remove 'new' operator when invoking Just
Browse files Browse the repository at this point in the history
* Use of 'new' operator with PureScript data constructors is not best practice
* Fixes runtime exceptions with purescript-backend-optimizer. Optimizer outputs data constructor as arrow functions.
  * https://github.com/aristanetworks/purescript-backend-optimizer
  • Loading branch information
aranchelk authored and fehrenbach committed Aug 28, 2022
1 parent 6fb203a commit 0192d2c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Data/HashMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ MapNode.prototype.lookup = function lookup(Nothing, Just, keyEquals, key, keyHas
if ((this.datamap & bit) !== 0) {
var i = index(this.datamap, bit);
if (keyEquals(key)(this.content[i * 2]))
return new Just(this.content[i * 2 + 1]);
return Just(this.content[i * 2 + 1]);
return Nothing;
}
if ((this.nodemap & bit) !== 0) {
Expand Down Expand Up @@ -486,7 +486,7 @@ function Collision(keys, values) {
Collision.prototype.lookup = function collisionLookup(Nothing, Just, keyEquals, key, keyHash, shift) {
for (var i = 0; i < this.keys.length; i++)
if (keyEquals(key)(this.keys[i]))
return new Just(this.values[i]);
return Just(this.values[i]);
return Nothing;
};

Expand Down

0 comments on commit 0192d2c

Please sign in to comment.