dart-lang / core

This repository is home to core Dart packages.
https://pub.dev/publishers/dart.dev
BSD 3-Clause "New" or "Revised" License
19 stars 7 forks source link

Use `values` iterator and `update` in map equality/hash #718

Closed jakemac53 closed 3 weeks ago

jakemac53 commented 3 weeks ago

Initially I tried using entries instead of a values iterator, but that was surprisingly slow. This appears to be a good middle ground (see history of this comment for old results).

Hashing is about the same, but much faster for maps which don't have O(1) lookup. Equality is much faster.

Benchmarks before:

DeepCollectionQualityUnordered.equals(RunTime): 7427.29020979021 us. DeepCollectionQualityUnordered.hash(RunTime): 217.8173707406213 us. DeepCollectionQuality.equals(RunTime): 2653.23875 us. DeepCollectionQuality.hash(RunTime): 178.1674653887114 us.

Benchmarks after:

DeepCollectionQualityUnordered.equals(RunTime): 4435.374 us. DeepCollectionQualityUnordered.hash(RunTime): 212.8631545473818 us. DeepCollectionQuality.equals(RunTime): 1989.1746626686656 us. DeepCollectionQuality.hash(RunTime): 178.3396697902722 us.

github-actions[bot] commented 3 weeks ago

Package publishing

Package Version Status Publish tag (post-merge)
package:characters 1.4.0 ready to publish characters-v1.4.0
package:args 2.6.1-wip WIP (no publish necessary)
package:async 2.12.0 already published at pub.dev
package:collection 1.19.1-wip WIP (no publish necessary)
package:convert 3.1.2 already published at pub.dev
package:crypto 3.0.6 already published at pub.dev
package:fixnum 1.1.1 already published at pub.dev
package:logging 1.3.0 already published at pub.dev
package:os_detect 2.0.3-wip WIP (no publish necessary)
package:path 1.9.1 already published at pub.dev
package:platform 3.1.6 already published at pub.dev
package:typed_data 1.4.0 already published at pub.dev

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

github-actions[bot] commented 3 weeks ago

PR Health

Breaking changes :heavy_check_mark: | Package | Change | Current Version | New Version | Needed Version | Looking good? | | :--- | :--- | ---: | ---: | ---: | ---: | |collection|None|1.19.1-wip|1.19.1-wip|1.19.1-wip|:heavy_check_mark:|
Changelog Entry :heavy_check_mark: | Package | Changed Files | | :--- | :--- | Changes to files need to be [accounted for](https://github.com/dart-lang/ecosystem/wiki/Changelog) in their respective changelogs.
Coverage :heavy_check_mark: | File | Coverage | | :--- | :--- | |pkgs/collection/lib/src/equality.dart| :green_heart: 89 % | This check for [test coverage](https://github.com/dart-lang/ecosystem/wiki/Test-Coverage) is informational (issues shown here will not fail the PR).
API leaks :heavy_check_mark: The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API. | Package | Leaked API symbols | | :--- | :--- |
License Headers :heavy_check_mark: ``` // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. ``` | Files | | :--- | | _no missing headers_ | All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header).
jakemac53 commented 3 weeks ago

cc @davidmorgan