Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library pub_semver.src.version_range; | 5 library pub_semver.src.version_range; |
| 6 | 6 |
| 7 import 'version.dart'; | 7 import 'version.dart'; |
| 8 import 'version_constraint.dart'; | 8 import 'version_constraint.dart'; |
| 9 | 9 |
| 10 /// Constrains versions to a fall within a given range. | 10 /// Constrains versions to a fall within a given range. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 | 59 |
| 60 bool operator ==(other) { | 60 bool operator ==(other) { |
| 61 if (other is! VersionRange) return false; | 61 if (other is! VersionRange) return false; |
| 62 | 62 |
| 63 return min == other.min && | 63 return min == other.min && |
| 64 max == other.max && | 64 max == other.max && |
| 65 includeMin == other.includeMin && | 65 includeMin == other.includeMin && |
| 66 includeMax == other.includeMax; | 66 includeMax == other.includeMax; |
| 67 } | 67 } |
| 68 | 68 |
| 69 int get hashCode => min.hashCode ^ (max.hashCode * 3) ^ | |
| 70 (includeMin.hashCode * 5) ^ (includeMax.hashCode * 7); | |
|
Bob Nystrom
2014/10/30 16:45:24
Idle thought: these multiplications can push the r
| |
| 71 | |
| 69 bool get isEmpty => false; | 72 bool get isEmpty => false; |
| 70 | 73 |
| 71 bool get isAny => min == null && max == null; | 74 bool get isAny => min == null && max == null; |
| 72 | 75 |
| 73 /// Tests if [other] falls within this version range. | 76 /// Tests if [other] falls within this version range. |
| 74 bool allows(Version other) { | 77 bool allows(Version other) { |
| 75 if (min != null) { | 78 if (min != null) { |
| 76 if (other < min) return false; | 79 if (other < min) return false; |
| 77 if (!includeMin && other == min) return false; | 80 if (!includeMin && other == min) return false; |
| 78 } | 81 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 if (max != null) { | 173 if (max != null) { |
| 171 if (min != null) buffer.write(' '); | 174 if (min != null) buffer.write(' '); |
| 172 buffer.write(includeMax ? '<=' : '<'); | 175 buffer.write(includeMax ? '<=' : '<'); |
| 173 buffer.write(max); | 176 buffer.write(max); |
| 174 } | 177 } |
| 175 | 178 |
| 176 if (min == null && max == null) buffer.write('any'); | 179 if (min == null && max == null) buffer.write('any'); |
| 177 return buffer.toString(); | 180 return buffer.toString(); |
| 178 } | 181 } |
| 179 } | 182 } |
| OLD | NEW |