Skip to content

Commit ddc7efc

Browse files
committed
ready for publish
1 parent 51eb48c commit ddc7efc

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## 1.0.0
1+
## 0.9.0
22

33
- Initial version.

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Overview
2+
3+
This is a simple Dart package that provides fast and secure equality comparison as a `mixin`. This provides great compatibility to exsiting code.
4+
5+
It optionally offers hash caching to improve the speed of e.g. `Map`'s and `Set`'s significantly.
6+
7+
By default the widely spread [Jenkins hash function](https://en.wikipedia.org/wiki/Jenkins_hash_function) is used, but you are free to also implement and provide your own hash engine, suiting your needs.
8+
9+
Objects of any kind are allowed into `hashParameters`. Simple types and the standard collections like `List`, `Iterable`, `Map` an `Set` are supported by default. When you use own classes make sure to use the `FastEquatable` mixin as well, or make sure at least `hashCode` and `operator ==` are overriden.
10+
11+
## Example
12+
13+
```dart
14+
class FastEquatableCached with FastEquatable {
15+
final String value1;
16+
final List<String>? value2;
17+
18+
FastEquatableCached(this.value1, this.value2);
19+
20+
@override
21+
//This is a immutable object, so we want to cache the hash
22+
bool get cacheHash => true;
23+
24+
@override
25+
List<Object?> get hashParameters => [value1, value2];
26+
}
27+
```
28+
29+
## Benchmark
30+
31+
In the `example` you will find a benchmark code, showing off the resulting speed improvement.
32+
33+
```
34+
equatable for 1000000 elements(RunTime): 8583044.5 us.
35+
fast_equatable (uncached) for 1000000 elements(RunTime): 8493327.5 us.
36+
fast_equatable (cached) for 1000000 elements(RunTime): 3329455.5 us.
37+
```

example/CHANGELOG.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/bin/example.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class EquatableBenchmark extends BenchmarkBase {
4848

4949
EquatableBenchmark(this._randsValA, this._randsValB)
5050
: assert(_randsValA.length == _randsValB.length),
51-
super('Equatable for ${_randsValA.length} elements');
51+
super('equatable for ${_randsValA.length} elements');
5252

5353
@override
5454
void setup() {
@@ -74,7 +74,7 @@ class FastEquatableUncachedBenchmark extends BenchmarkBase {
7474

7575
FastEquatableUncachedBenchmark(this._randsValA, this._randsValB)
7676
: assert(_randsValA.length == _randsValB.length),
77-
super('Fast Equatable (uncached) for ${_randsValA.length} elements');
77+
super('fast_equatable (uncached) for ${_randsValA.length} elements');
7878

7979
@override
8080
void setup() {
@@ -100,7 +100,7 @@ class FastEquatableCachedBenchmark extends BenchmarkBase {
100100

101101
FastEquatableCachedBenchmark(this._randsValA, this._randsValB)
102102
: assert(_randsValA.length == _randsValB.length),
103-
super('Fast Equatable (cached) for ${_randsValA.length} elements');
103+
super('fast_equatable (cached) for ${_randsValA.length} elements');
104104

105105
@override
106106
void setup() {

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: fast_equatable
2-
description: A starting point for Dart libraries or applications.
3-
version: 1.0.0
4-
# homepage: https://www.example.com
2+
description: A simple Dart package that provides fast and secure equality comparison as a mixin. It optionally offers hash caching to improve the speed of Map's and Set's significantly.
3+
version: 0.9.0
4+
repository: https://github.com/FaFre/fast_equatable
55

66
environment:
77
sdk: ">=2.12.0 <3.0.0"

0 commit comments

Comments
 (0)