Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
deprecated hashValues and hashList
Browse files Browse the repository at this point in the history
  • Loading branch information
werainkhatri committed Jan 5, 2022
1 parent 154bd96 commit c2913f9
Show file tree
Hide file tree
Showing 26 changed files with 125 additions and 311 deletions.
12 changes: 6 additions & 6 deletions lib/ui/geometry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ abstract class OffsetBase {
}

@override
int get hashCode => hashValues(_dx, _dy);
int get hashCode => Object.hash(_dx, _dy);

@override
String toString() => 'OffsetBase(${_dx.toStringAsFixed(1)}, ${_dy.toStringAsFixed(1)})';
Expand Down Expand Up @@ -341,7 +341,7 @@ class Offset extends OffsetBase {
}

@override
int get hashCode => hashValues(dx, dy);
int get hashCode => Object.hash(dx, dy);

@override
String toString() => 'Offset(${dx.toStringAsFixed(1)}, ${dy.toStringAsFixed(1)})';
Expand Down Expand Up @@ -613,7 +613,7 @@ class Size extends OffsetBase {
}

@override
int get hashCode => hashValues(_dx, _dy);
int get hashCode => Object.hash(_dx, _dy);

@override
String toString() => 'Size(${width.toStringAsFixed(1)}, ${height.toStringAsFixed(1)})';
Expand Down Expand Up @@ -907,7 +907,7 @@ class Rect {
}

@override
int get hashCode => hashValues(left, top, right, bottom);
int get hashCode => Object.hash(left, top, right, bottom);

@override
String toString() => 'Rect.fromLTRB(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)})';
Expand Down Expand Up @@ -1033,7 +1033,7 @@ class Radius {
}

@override
int get hashCode => hashValues(x, y);
int get hashCode => Object.hash(x, y);

@override
String toString() {
Expand Down Expand Up @@ -1645,7 +1645,7 @@ class RRect {
}

@override
int get hashCode => hashValues(left, top, right, bottom,
int get hashCode => Object.hash(left, top, right, bottom,
tlRadiusX, tlRadiusY, trRadiusX, trRadiusY,
blRadiusX, blRadiusY, brRadiusX, brRadiusY);

Expand Down
139 changes: 25 additions & 114 deletions lib/ui/hash_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,122 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.


// @dart = 2.12
part of dart.ui;

class _HashEnd { const _HashEnd(); }
const _HashEnd _hashEnd = _HashEnd();

/// Jenkins hash function, optimized for small integers.
//
// Borrowed from the dart sdk: sdk/lib/math/jenkins_smi_hash.dart.
class _Jenkins {
static int combine(int hash, Object? o) {
assert(o is! Iterable);
hash = 0x1fffffff & (hash + o.hashCode);
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
return hash ^ (hash >> 6);
}

static int finish(int hash) {
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
hash = hash ^ (hash >> 11);
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
}
}

/// Combine up to twenty objects' hash codes into one value.
///
/// If you only need to handle one object's hash code, then just refer to its
/// [Object.hashCode] getter directly.
///
/// If you need to combine an arbitrary number of objects from a [List] or other
/// [Iterable], use [hashList]. The output of [hashList] can be used as one of
/// the arguments to this function.
///
/// For example:
///
/// ```dart
/// int hashCode => hashValues(foo, bar, hashList(quux), baz);
/// ```
@Deprecated(
'Use Object.hash() instead '
'This feature was deprecated in v2.9.0-0.1.pre'
)
int hashValues(
Object? arg01, Object? arg02, [ Object? arg03 = _hashEnd,
Object? arg04 = _hashEnd, Object? arg05 = _hashEnd, Object? arg06 = _hashEnd,
Object? arg07 = _hashEnd, Object? arg08 = _hashEnd, Object? arg09 = _hashEnd,
Object? arg10 = _hashEnd, Object? arg11 = _hashEnd, Object? arg12 = _hashEnd,
Object? arg13 = _hashEnd, Object? arg14 = _hashEnd, Object? arg15 = _hashEnd,
Object? arg16 = _hashEnd, Object? arg17 = _hashEnd, Object? arg18 = _hashEnd,
Object? arg19 = _hashEnd, Object? arg20 = _hashEnd ]) {
int result = 0;
result = _Jenkins.combine(result, arg01);
result = _Jenkins.combine(result, arg02);
if (!identical(arg03, _hashEnd)) {
result = _Jenkins.combine(result, arg03);
if (!identical(arg04, _hashEnd)) {
result = _Jenkins.combine(result, arg04);
if (!identical(arg05, _hashEnd)) {
result = _Jenkins.combine(result, arg05);
if (!identical(arg06, _hashEnd)) {
result = _Jenkins.combine(result, arg06);
if (!identical(arg07, _hashEnd)) {
result = _Jenkins.combine(result, arg07);
if (!identical(arg08, _hashEnd)) {
result = _Jenkins.combine(result, arg08);
if (!identical(arg09, _hashEnd)) {
result = _Jenkins.combine(result, arg09);
if (!identical(arg10, _hashEnd)) {
result = _Jenkins.combine(result, arg10);
if (!identical(arg11, _hashEnd)) {
result = _Jenkins.combine(result, arg11);
if (!identical(arg12, _hashEnd)) {
result = _Jenkins.combine(result, arg12);
if (!identical(arg13, _hashEnd)) {
result = _Jenkins.combine(result, arg13);
if (!identical(arg14, _hashEnd)) {
result = _Jenkins.combine(result, arg14);
if (!identical(arg15, _hashEnd)) {
result = _Jenkins.combine(result, arg15);
if (!identical(arg16, _hashEnd)) {
result = _Jenkins.combine(result, arg16);
if (!identical(arg17, _hashEnd)) {
result = _Jenkins.combine(result, arg17);
if (!identical(arg18, _hashEnd)) {
result = _Jenkins.combine(result, arg18);
if (!identical(arg19, _hashEnd)) {
result = _Jenkins.combine(result, arg19);
if (!identical(arg20, _hashEnd)) {
result = _Jenkins.combine(result, arg20);
// I can see my house from here!
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return _Jenkins.finish(result);
}
Object? arg01, Object? arg02, [
Object? arg03, Object? arg04,
Object? arg05, Object? arg06,
Object? arg07, Object? arg08,
Object? arg09, Object? arg10,
Object? arg11, Object? arg12,
Object? arg13, Object? arg14,
Object? arg15, Object? arg16,
Object? arg17, Object? arg18,
Object? arg19, Object? arg20, ]
) => Object.hash(
arg01, arg02, arg03, arg04, arg05, arg06,
arg07, arg08, arg09, arg10, arg11, arg12,
arg13, arg14, arg15, arg16, arg17, arg18,
arg19, arg20,
);

/// Combine the [Object.hashCode] values of an arbitrary number of objects from
/// an [Iterable] into one value. This function will return the same value if
/// given null as if given an empty list.
int hashList(Iterable<Object?>? arguments) {
int result = 0;
if (arguments != null) {
for (final Object? argument in arguments)
result = _Jenkins.combine(result, argument);
}
return _Jenkins.finish(result);
}
@Deprecated(
'Use Object.hashAll() or Object.hashAllUnordered() instead '
'This feature was deprecated in v2.9.0-0.1.pre'
)
int hashList(Iterable<Object?>? arguments) => Object.hashAll(arguments ?? <Object?>[]);
14 changes: 7 additions & 7 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2962,7 +2962,7 @@ class MaskFilter {
}

@override
int get hashCode => hashValues(_style, _sigma);
int get hashCode => Object.hash(_style, _sigma);

@override
String toString() => 'MaskFilter.blur($_style, ${_sigma.toStringAsFixed(1)})';
Expand Down Expand Up @@ -3121,7 +3121,7 @@ class ColorFilter implements ImageFilter {
}

@override
int get hashCode => hashValues(_color, _blendMode, hashList(_matrix), _type);
int get hashCode => Object.hash(_color, _blendMode, Object.hashAll(_matrix ?? <Object?>[]), _type);

@override
String get _shortDescription {
Expand Down Expand Up @@ -3279,7 +3279,7 @@ class _MatrixImageFilter implements ImageFilter {
}

@override
int get hashCode => hashValues(filterQuality, hashList(data));
int get hashCode => Object.hash(filterQuality, Object.hashAll(data));
}

class _GaussianBlurImageFilter implements ImageFilter {
Expand Down Expand Up @@ -3320,7 +3320,7 @@ class _GaussianBlurImageFilter implements ImageFilter {
}

@override
int get hashCode => hashValues(sigmaX, sigmaY);
int get hashCode => Object.hash(sigmaX, sigmaY);
}

class _ComposeImageFilter implements ImageFilter {
Expand Down Expand Up @@ -3350,7 +3350,7 @@ class _ComposeImageFilter implements ImageFilter {
}

@override
int get hashCode => hashValues(innerFilter, outerFilter);
int get hashCode => Object.hash(innerFilter, outerFilter);
}

/// An [ImageFilter] that is backed by a native SkImageFilter.
Expand Down Expand Up @@ -3905,7 +3905,7 @@ class _FragmentShader extends Shader {
}

@override
int get hashCode => hashValues(_builder, hashList(_floatUniforms), hashList(_samplerUniforms));
int get hashCode => Object.hash(_builder, Object.hashAll(_floatUniforms), Object.hashAll(_samplerUniforms));
}

/// Defines how a list of points is interpreted when drawing a set of triangles.
Expand Down Expand Up @@ -5321,7 +5321,7 @@ class Shadow {
}

@override
int get hashCode => hashValues(color, offset, blurRadius);
int get hashCode => Object.hash(color, offset, blurRadius);

// Serialize [shadows] into ByteData. The format is a single uint_32_t at
// the beginning indicating the number of shadows, followed by _kBytesPerShadow
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ class DisplayFeature {
}

@override
int get hashCode => hashValues(bounds, type, state);
int get hashCode => Object.hash(bounds, type, state);

@override
String toString() {
Expand Down Expand Up @@ -1894,7 +1894,7 @@ class Locale {
}

@override
int get hashCode => hashValues(languageCode, scriptCode, countryCode == '' ? null : countryCode);
int get hashCode => Object.hash(languageCode, scriptCode, countryCode == '' ? null : countryCode);

static Locale? _cachedLocale;
static String? _cachedLocaleString;
Expand Down
18 changes: 9 additions & 9 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ class FontFeature {
}

@override
int get hashCode => hashValues(feature, value);
int get hashCode => Object.hash(feature, value);

@override
String toString() => "FontFeature('$feature', $value)";
Expand Down Expand Up @@ -1720,7 +1720,7 @@ class TextHeightBehavior {

@override
int get hashCode {
return hashValues(
return Object.hash(
applyHeightToFirstAscent,
applyHeightToLastDescent,
leadingDistribution.index,
Expand Down Expand Up @@ -2013,7 +2013,7 @@ class TextStyle {
}

@override
int get hashCode => hashValues(hashList(_encoded), _leadingDistribution, _fontFamily, _fontFamilyFallback, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground, hashList(_shadows), _decorationThickness, hashList(_fontFeatures));
int get hashCode => Object.hash(Object.hashAll(_encoded), _leadingDistribution, _fontFamily, _fontFamilyFallback, _fontSize, _letterSpacing, _wordSpacing, _height, _locale, _background, _foreground, Object.hashAll(_shadows ?? <Object?>[]), _decorationThickness, Object.hashAll(_fontFeatures ?? <Object?>[]));

@override
String toString() {
Expand Down Expand Up @@ -2257,7 +2257,7 @@ class ParagraphStyle {
}

@override
int get hashCode => hashValues(hashList(_encoded), _fontFamily, _fontSize, _height, _ellipsis, _locale, _leadingDistribution);
int get hashCode => Object.hash(Object.hashAll(_encoded), _fontFamily, _fontSize, _height, _ellipsis, _locale, _leadingDistribution);

@override
String toString() {
Expand Down Expand Up @@ -2452,7 +2452,7 @@ class StrutStyle {
}

@override
int get hashCode => hashValues(hashList(_encoded.buffer.asInt8List()), _fontFamily, _leadingDistribution);
int get hashCode => Object.hash(Object.hashAll(_encoded.buffer.asInt8List()), _fontFamily, _leadingDistribution);

}

Expand Down Expand Up @@ -2618,7 +2618,7 @@ class TextBox {
}

@override
int get hashCode => hashValues(left, top, right, bottom, direction);
int get hashCode => Object.hash(left, top, right, bottom, direction);

@override
String toString() => 'TextBox.fromLTRBD(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)}, $direction)';
Expand Down Expand Up @@ -2725,7 +2725,7 @@ class TextPosition {
}

@override
int get hashCode => hashValues(offset, affinity);
int get hashCode => Object.hash(offset, affinity);

@override
String toString() {
Expand Down Expand Up @@ -2809,7 +2809,7 @@ class TextRange {
}

@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
start.hashCode,
end.hashCode,
);
Expand Down Expand Up @@ -3092,7 +3092,7 @@ class LineMetrics {
}

@override
int get hashCode => hashValues(hardBreak, ascent, descent, unscaledAscent, height, width, left, baseline, lineNumber);
int get hashCode => Object.hash(hardBreak, ascent, descent, unscaledAscent, height, width, left, baseline, lineNumber);

@override
String toString() {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ class GestureSettings {
}

@override
int get hashCode => hashValues(physicalTouchSlop, physicalDoubleTapSlop);
int get hashCode => Object.hash(physicalTouchSlop, physicalDoubleTapSlop);

@override
String toString() => 'GestureSettings(physicalTouchSlop: $physicalTouchSlop, physicalDoubleTapSlop: $physicalDoubleTapSlop)';
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/lib/src/engine/canvaskit/color_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CkBlendModeColorFilter extends CkColorFilter {
}

@override
int get hashCode => ui.hashValues(color, blendMode);
int get hashCode => Object.hash(color, blendMode);

@override
bool operator ==(Object other) {
Expand Down Expand Up @@ -126,7 +126,7 @@ class CkMatrixColorFilter extends CkColorFilter {
}

@override
int get hashCode => ui.hashList(matrix);
int get hashCode => Object.hashAll(matrix);

@override
bool operator ==(Object other) {
Expand Down
Loading

0 comments on commit c2913f9

Please sign in to comment.