-
Notifications
You must be signed in to change notification settings - Fork 248
Conversation
} | ||
_mapEqual(Map a, Map b) => a.length == b.length | ||
? a.keys.every((k) => b.containsKey(k) && a[k] == b[k]) | ||
: false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a.length == b.length && a.keys.every((k) => b.containsKey(k) && a[k] == b[k])
Btw, what is wrong with a regular a == b
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a == b
would return true only if a and b are the same map, not if they have the same content.
Thanks for the short version, will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes. For some reason I thought ==
was value based by default in Dart since there is no equals
method.
b.containsKey(k) && a[k] == b[k]
seems rather inefficient... but I can't really see any better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a MapEquality
in the collections package. Why not use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very generic and then may be overkill ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
child._prev = prev; | ||
if (prev == null) _childHead = child; else prev._next = child; | ||
if (next == null) _childTail = child; else next._prev = child; | ||
if (prev == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the original code much more readable. Can you revert this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted in the last commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops already merged... I'll re-submit the optim as it seems to have been reverted altogether with the style !
@chalin: MapEquality is in the collections pub package. |
https://groups.google.com/a/dartlang.org/forum/#!topic/misc/1gCdqCAhghM has some interesting replies |
2 optimizations:
createChild()
are always last in llist,_mapEqual()
can stop comparing values on first mismatch& some minor cleanup