diff --git a/lib/ui/geometry.dart b/lib/ui/geometry.dart index cf4bb483917a9..ce1d6ee23c773 100644 --- a/lib/ui/geometry.dart +++ b/lib/ui/geometry.dart @@ -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)})'; @@ -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)})'; @@ -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)})'; @@ -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)})'; @@ -1033,7 +1033,7 @@ class Radius { } @override - int get hashCode => hashValues(x, y); + int get hashCode => Object.hash(x, y); @override String toString() { @@ -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); diff --git a/lib/ui/hash_codes.dart b/lib/ui/hash_codes.dart index 71da5b3642b2e..63b0b74857752 100644 --- a/lib/ui/hash_codes.dart +++ b/lib/ui/hash_codes.dart @@ -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? 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? arguments) => Object.hashAll(arguments ?? []); diff --git a/lib/ui/painting.dart b/lib/ui/painting.dart index 7fb35cf74c143..382c7e532fa51 100644 --- a/lib/ui/painting.dart +++ b/lib/ui/painting.dart @@ -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)})'; @@ -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 ?? []), _type); @override String get _shortDescription { @@ -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 { @@ -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 { @@ -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. @@ -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. @@ -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 diff --git a/lib/ui/platform_dispatcher.dart b/lib/ui/platform_dispatcher.dart index b57a7d5409fbe..3e05462cfd94d 100644 --- a/lib/ui/platform_dispatcher.dart +++ b/lib/ui/platform_dispatcher.dart @@ -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() { @@ -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; diff --git a/lib/ui/text.dart b/lib/ui/text.dart index a5884beca299d..13e51c86a36e3 100644 --- a/lib/ui/text.dart +++ b/lib/ui/text.dart @@ -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)"; @@ -1720,7 +1720,7 @@ class TextHeightBehavior { @override int get hashCode { - return hashValues( + return Object.hash( applyHeightToFirstAscent, applyHeightToLastDescent, leadingDistribution.index, @@ -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 ?? []), _decorationThickness, Object.hashAll(_fontFeatures ?? [])); @override String toString() { @@ -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() { @@ -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); } @@ -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)'; @@ -2725,7 +2725,7 @@ class TextPosition { } @override - int get hashCode => hashValues(offset, affinity); + int get hashCode => Object.hash(offset, affinity); @override String toString() { @@ -2809,7 +2809,7 @@ class TextRange { } @override - int get hashCode => hashValues( + int get hashCode => Object.hash( start.hashCode, end.hashCode, ); @@ -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() { diff --git a/lib/ui/window.dart b/lib/ui/window.dart index 31e63036081b4..2bf9482996ebd 100644 --- a/lib/ui/window.dart +++ b/lib/ui/window.dart @@ -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)'; diff --git a/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart b/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart index 7c6af4760a777..7c23b829836dd 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart @@ -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) { @@ -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) { diff --git a/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart b/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart index acbd5e8560333..e81f9b36ae862 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart @@ -803,7 +803,7 @@ class EmbeddedViewParams { } @override - int get hashCode => ui.hashValues(offset, size, mutators); + int get hashCode => Object.hash(offset, size, mutators); } enum MutatorType { @@ -881,7 +881,7 @@ class Mutator { } @override - int get hashCode => ui.hashValues(type, rect, rrect, path, matrix, alpha); + int get hashCode => Object.hash(type, rect, rrect, path, matrix, alpha); } /// A stack of mutators that can be applied to an embedded view. @@ -927,7 +927,7 @@ class MutatorsStack extends Iterable { } @override - int get hashCode => ui.hashList(_mutators); + int get hashCode => Object.hashAll(_mutators); @override Iterator get iterator => _mutators.reversed.iterator; diff --git a/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart b/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart index 44d7fd01bfbe0..319256fcad98b 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart @@ -602,7 +602,7 @@ class CodeunitRange { } @override - int get hashCode => ui.hashValues(start, end); + int get hashCode => Object.hash(start, end); @override String toString() => '[$start, $end]'; diff --git a/lib/web_ui/lib/src/engine/canvaskit/image_filter.dart b/lib/web_ui/lib/src/engine/canvaskit/image_filter.dart index dc74021b69f1f..faf3fb992d0cd 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/image_filter.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/image_filter.dart @@ -124,7 +124,7 @@ class _CkBlurImageFilter extends CkImageFilter { } @override - int get hashCode => ui.hashValues(sigmaX, sigmaY, tileMode); + int get hashCode => Object.hash(sigmaX, sigmaY, tileMode); @override String toString() { @@ -161,7 +161,7 @@ class _CkMatrixImageFilter extends CkImageFilter { } @override - int get hashCode => ui.hashValues(filterQuality, ui.hashList(matrix)); + int get hashCode => Object.hash(filterQuality, Object.hashAll(matrix)); @override String toString() => 'ImageFilter.matrix($matrix, $filterQuality)'; diff --git a/lib/web_ui/lib/src/engine/canvaskit/text.dart b/lib/web_ui/lib/src/engine/canvaskit/text.dart index afa865166de76..9b362d2a2f21d 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/text.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/text.dart @@ -502,7 +502,7 @@ class CkStrutStyle implements ui.StrutStyle { } @override - int get hashCode => ui.hashValues( + int get hashCode => Object.hash( _fontFamily, _fontFamilyFallback, _fontSize, diff --git a/lib/web_ui/lib/src/engine/html/path/path_ref.dart b/lib/web_ui/lib/src/engine/html/path/path_ref.dart index 1cbc082a836a4..8f8f8261308c7 100644 --- a/lib/web_ui/lib/src/engine/html/path/path_ref.dart +++ b/lib/web_ui/lib/src/engine/html/path/path_ref.dart @@ -312,7 +312,7 @@ class PathRef { } @override - int get hashCode => ui.hashValues(fSegmentMask, + int get hashCode => Object.hash(fSegmentMask, fPoints, _conicWeights, _fVerbs); bool equals(PathRef ref) { diff --git a/lib/web_ui/lib/src/engine/html/shaders/shader.dart b/lib/web_ui/lib/src/engine/html/shaders/shader.dart index 0ae291470b0f1..c1e53cfc27dc5 100644 --- a/lib/web_ui/lib/src/engine/html/shaders/shader.dart +++ b/lib/web_ui/lib/src/engine/html/shaders/shader.dart @@ -711,7 +711,7 @@ class _BlurEngineImageFilter extends EngineImageFilter { } @override - int get hashCode => ui.hashValues(sigmaX, sigmaY, tileMode); + int get hashCode => Object.hash(sigmaX, sigmaY, tileMode); @override String toString() { @@ -741,7 +741,7 @@ class _MatrixEngineImageFilter extends EngineImageFilter { } @override - int get hashCode => ui.hashValues(ui.hashList(webMatrix), filterQuality); + int get hashCode => Object.hash(Object.hashAll(webMatrix), filterQuality); @override String toString() { diff --git a/lib/web_ui/lib/src/engine/text/line_breaker.dart b/lib/web_ui/lib/src/engine/text/line_breaker.dart index c8232d4d84188..7a0e596f55aac 100644 --- a/lib/web_ui/lib/src/engine/text/line_breaker.dart +++ b/lib/web_ui/lib/src/engine/text/line_breaker.dart @@ -86,7 +86,7 @@ class LineBreakResult { type == LineBreakType.mandatory || type == LineBreakType.endOfText; @override - int get hashCode => ui.hashValues( + int get hashCode => Object.hash( index, indexWithoutTrailingNewlines, indexWithoutTrailingSpaces, diff --git a/lib/web_ui/lib/src/engine/text/paragraph.dart b/lib/web_ui/lib/src/engine/text/paragraph.dart index dea366f081a69..38872772ac61b 100644 --- a/lib/web_ui/lib/src/engine/text/paragraph.dart +++ b/lib/web_ui/lib/src/engine/text/paragraph.dart @@ -126,7 +126,7 @@ class EngineLineMetrics implements ui.LineMetrics { } @override - int get hashCode => ui.hashValues( + int get hashCode => Object.hash( displayText, startIndex, endIndex, @@ -286,7 +286,7 @@ class EngineParagraphStyle implements ui.ParagraphStyle { @override int get hashCode { - return ui.hashValues( + return Object.hash( textAlign, textDirection, fontWeight, @@ -490,7 +490,7 @@ class EngineTextStyle implements ui.TextStyle { } @override - int get hashCode => ui.hashValues( + int get hashCode => Object.hash( color, decoration, decorationColor, @@ -597,7 +597,7 @@ class EngineStrutStyle implements ui.StrutStyle { } @override - int get hashCode => ui.hashValues( + int get hashCode => Object.hash( _fontFamily, _fontFamilyFallback, _fontSize, diff --git a/lib/web_ui/lib/src/engine/text/ruler.dart b/lib/web_ui/lib/src/engine/text/ruler.dart index 9ef928d15a1e6..74b3e0188a97f 100644 --- a/lib/web_ui/lib/src/engine/text/ruler.dart +++ b/lib/web_ui/lib/src/engine/text/ruler.dart @@ -159,7 +159,7 @@ class ParagraphGeometricStyle { } @override - int get hashCode => _cachedHashCode ??= ui.hashValues( + int get hashCode => _cachedHashCode ??= Object.hash( textDirection, textAlign, fontWeight, @@ -220,11 +220,11 @@ class TextHeightStyle { } @override - late final int hashCode = ui.hashValues( + late final int hashCode = Object.hash( fontFamily, fontSize, height, - ui.hashList(fontFeatures), + Object.hashAll(fontFeatures ?? []), ); } diff --git a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart index 5b9c0437ffb89..19846b8f71966 100644 --- a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart +++ b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart @@ -525,7 +525,7 @@ class EditingState { bool get isValid => baseOffset! >= 0 && extentOffset! >= 0; @override - int get hashCode => ui.hashValues(text, baseOffset, extentOffset); + int get hashCode => Object.hash(text, baseOffset, extentOffset); @override bool operator ==(Object other) { diff --git a/lib/web_ui/lib/src/ui/geometry.dart b/lib/web_ui/lib/src/ui/geometry.dart index 0882cfaf83f41..db1dcb0cf4009 100644 --- a/lib/web_ui/lib/src/ui/geometry.dart +++ b/lib/web_ui/lib/src/ui/geometry.dart @@ -28,7 +28,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)})'; @@ -82,7 +82,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)})'; @@ -169,7 +169,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)})'; @@ -321,7 +321,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)})'; @@ -374,7 +374,7 @@ class Radius { } @override - int get hashCode => hashValues(x, y); + int get hashCode => Object.hash(x, y); @override String toString() { @@ -870,7 +870,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); diff --git a/lib/web_ui/lib/src/ui/hash_codes.dart b/lib/web_ui/lib/src/ui/hash_codes.dart index b94b22a33ab87..2596629c38786 100644 --- a/lib/web_ui/lib/src/ui/hash_codes.dart +++ b/lib/web_ui/lib/src/ui/hash_codes.dart @@ -4,124 +4,30 @@ part of 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. -abstract class _Jenkins { - // This class is not meant to be instantiated or extended; this constructor - // prevents instantiation and extension. - _Jenkins._(); - - static int combine(int hash, Object? o) { - assert(o is! Iterable); - hash = 0x1fffffff & (hash + o.hashCode); - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - hash = hash ^ (hash >> 6); - return hash; - } - - static int finish(int hash) { - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - hash = hash ^ (hash >> 11); - hash = 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - return hash; - } -} - +@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 (arg03 != _hashEnd) { - result = _Jenkins.combine(result, arg03); - if (arg04 != _hashEnd) { - result = _Jenkins.combine(result, arg04); - if (arg05 != _hashEnd) { - result = _Jenkins.combine(result, arg05); - if (arg06 != _hashEnd) { - result = _Jenkins.combine(result, arg06); - if (arg07 != _hashEnd) { - result = _Jenkins.combine(result, arg07); - if (arg08 != _hashEnd) { - result = _Jenkins.combine(result, arg08); - if (arg09 != _hashEnd) { - result = _Jenkins.combine(result, arg09); - if (arg10 != _hashEnd) { - result = _Jenkins.combine(result, arg10); - if (arg11 != _hashEnd) { - result = _Jenkins.combine(result, arg11); - if (arg12 != _hashEnd) { - result = _Jenkins.combine(result, arg12); - if (arg13 != _hashEnd) { - result = _Jenkins.combine(result, arg13); - if (arg14 != _hashEnd) { - result = _Jenkins.combine(result, arg14); - if (arg15 != _hashEnd) { - result = _Jenkins.combine(result, arg15); - if (arg16 != _hashEnd) { - result = _Jenkins.combine(result, arg16); - if (arg17 != _hashEnd) { - result = _Jenkins.combine(result, arg17); - if (arg18 != _hashEnd) { - result = _Jenkins.combine(result, arg18); - if (arg19 != _hashEnd) { - result = _Jenkins.combine(result, arg19); - if (arg20 != _hashEnd) { - result = _Jenkins.combine(result, arg20); - // I can see my house from here! - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - return _Jenkins.finish(result); -} - -int hashList(Iterable? arguments) { - int result = 0; - if (arguments != null) { - for (final Object? argument in arguments) - result = _Jenkins.combine(result, argument); - } - 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, + ); + +@Deprecated( + 'Use Object.hashAll() or Object.hashAllUnordered() instead ' + 'This feature was deprecated in v2.9.0-0.1.pre' +) +int hashList(Iterable? arguments) => Object.hashAll(arguments ?? []); diff --git a/lib/web_ui/lib/src/ui/painting.dart b/lib/web_ui/lib/src/ui/painting.dart index 98a9213bb1e06..86a93226fedf7 100644 --- a/lib/web_ui/lib/src/ui/painting.dart +++ b/lib/web_ui/lib/src/ui/painting.dart @@ -383,7 +383,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)})'; @@ -706,7 +706,7 @@ class Shadow { } @override - int get hashCode => hashValues(color, offset, blurRadius); + int get hashCode => Object.hash(color, offset, blurRadius); @override String toString() => 'TextShadow($color, $offset, $blurRadius)'; diff --git a/lib/web_ui/lib/src/ui/platform_dispatcher.dart b/lib/web_ui/lib/src/ui/platform_dispatcher.dart index 1027aa7f9b12a..ec64517caedfd 100644 --- a/lib/web_ui/lib/src/ui/platform_dispatcher.dart +++ b/lib/web_ui/lib/src/ui/platform_dispatcher.dart @@ -351,7 +351,7 @@ class DisplayFeature { } @override - int get hashCode => hashValues(bounds, type, state); + int get hashCode => Object.hash(bounds, type, state); @override String toString() { @@ -506,7 +506,7 @@ class Locale { } @override - int get hashCode => hashValues(languageCode, scriptCode, countryCode); + int get hashCode => Object.hash(languageCode, scriptCode, countryCode); @override String toString() => _rawToString('_'); diff --git a/lib/web_ui/lib/src/ui/text.dart b/lib/web_ui/lib/src/ui/text.dart index a076c6bcd8fe4..ff3a785c9b1bb 100644 --- a/lib/web_ui/lib/src/ui/text.dart +++ b/lib/web_ui/lib/src/ui/text.dart @@ -173,7 +173,7 @@ class FontFeature { } @override - int get hashCode => hashValues(feature, value); + int get hashCode => Object.hash(feature, value); @override String toString() => "FontFeature('$feature', $value)"; @@ -274,7 +274,7 @@ class TextHeightBehavior { @override int get hashCode { - return hashValues( + return Object.hash( applyHeightToFirstAscent, applyHeightToLastDescent, ); @@ -532,7 +532,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() { @@ -565,7 +565,7 @@ class TextPosition { } @override - int get hashCode => hashValues(offset, affinity); + int get hashCode => Object.hash(offset, affinity); @override String toString() { @@ -613,7 +613,7 @@ class TextRange { } @override - int get hashCode => hashValues( + int get hashCode => Object.hash( start.hashCode, end.hashCode, ); diff --git a/lib/web_ui/lib/src/ui/window.dart b/lib/web_ui/lib/src/ui/window.dart index d88e6dc5a56fa..374a947bbcc5e 100644 --- a/lib/web_ui/lib/src/ui/window.dart +++ b/lib/web_ui/lib/src/ui/window.dart @@ -290,7 +290,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)'; diff --git a/lib/web_ui/test/engine/profiler_test.dart b/lib/web_ui/test/engine/profiler_test.dart index 4bce4c906c31a..2fd9e420afcf7 100644 --- a/lib/web_ui/test/engine/profiler_test.dart +++ b/lib/web_ui/test/engine/profiler_test.dart @@ -9,7 +9,6 @@ import 'dart:js_util' as js_util; import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; -import 'package:ui/ui.dart'; import '../spy.dart'; @@ -138,7 +137,7 @@ class BenchmarkDatapoint { final num value; @override - int get hashCode => hashValues(name, value); + int get hashCode => Object.hash(name, value); @override bool operator ==(Object other) { diff --git a/lib/web_ui/test/hash_codes_test.dart b/lib/web_ui/test/hash_codes_test.dart index 7f56a727b6811..1fa397b32dcd6 100644 --- a/lib/web_ui/test/hash_codes_test.dart +++ b/lib/web_ui/test/hash_codes_test.dart @@ -4,7 +4,6 @@ import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; -import 'package:ui/ui.dart'; // The biggest integer value that can be represented in JavaScript is 1 << 53. // However, the 1 << 53 expression cannot be used in JavaScript because that @@ -17,9 +16,9 @@ void main() { } void testMain() { - test('hashValues can hash lots of huge values effectively', () { + test('Object.hash can hash lots of huge values effectively', () { expect( - hashValues( + Object.hash( _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, @@ -41,11 +40,11 @@ void testMain() { _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, ), - 496984395, + 41747581, ); // Hash a slightly smaller number to verify that the hash code is different. expect( - hashValues( + Object.hash( _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, @@ -67,13 +66,13 @@ void testMain() { _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt - 1, ), - 455584273, + 356874216, ); }); - test('hashList can hash lots of huge values effectively', () { + test('Object.hashAll can hash lots of huge values effectively', () { expect( - hashList([ + Object.hashAll([ _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, @@ -95,11 +94,11 @@ void testMain() { _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, ]), - 496984395, + 41747581, ); // Hash a slightly smaller number to verify that the hash code is different. expect( - hashList([ + Object.hashAll([ _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt, @@ -121,7 +120,7 @@ void testMain() { _kBiggestExactJavaScriptInt, _kBiggestExactJavaScriptInt - 1, ]), - 455584273, + 356874216, ); }); } diff --git a/lib/web_ui/test/text/line_breaker_test.dart b/lib/web_ui/test/text/line_breaker_test.dart index 32673dc91233a..c5c6b6083875e 100644 --- a/lib/web_ui/test/text/line_breaker_test.dart +++ b/lib/web_ui/test/text/line_breaker_test.dart @@ -6,7 +6,6 @@ import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; -import 'package:ui/ui.dart'; import 'line_breaker_test_helper.dart'; import 'line_breaker_test_raw_data.dart'; @@ -310,7 +309,7 @@ class Line { final LineBreakType breakType; @override - int get hashCode => hashValues(text, breakType); + int get hashCode => Object.hash(text, breakType); @override bool operator ==(Object other) {