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

Deprecates hashValues and hashList #30674

Merged
merged 7 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 9 additions & 1 deletion lib/ui/hash_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// 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();

// ignore: avoid_classes_with_only_static_members
/// Jenkins hash function, optimized for small integers.
//
// Borrowed from the dart sdk: sdk/lib/math/jenkins_smi_hash.dart.
Expand Down Expand Up @@ -41,6 +41,10 @@ class _Jenkins {
/// ```dart
/// int hashCode => hashValues(foo, bar, hashList(quux), baz);
/// ```
@Deprecated(
'Use Object.hash() instead. '
'This feature was deprecated in v3.1.0-0.0.pre.897'
)
int hashValues(
Object? arg01, Object? arg02, [ Object? arg03 = _hashEnd,
Object? arg04 = _hashEnd, Object? arg05 = _hashEnd, Object? arg06 = _hashEnd,
Expand Down Expand Up @@ -113,6 +117,10 @@ int hashValues(
/// 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.
@Deprecated(
'Use Object.hashAll() or Object.hashAllUnordered() instead. '
'This feature was deprecated in v3.1.0-0.0.pre.897'
)
int hashList(Iterable<Object?>? arguments) {
int result = 0;
if (arguments != null) {
Expand Down
16 changes: 8 additions & 8 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3009,7 +3009,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 @@ -3168,7 +3168,7 @@ class ColorFilter implements ImageFilter {
}

@override
int get hashCode => hashValues(_color, _blendMode, hashList(_matrix), _type);
int get hashCode => Object.hash(_color, _blendMode, _matrix == null ? null : Object.hashAll(_matrix!), _type);

@override
String get _shortDescription {
Expand Down Expand Up @@ -3342,7 +3342,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 @@ -3383,7 +3383,7 @@ class _GaussianBlurImageFilter implements ImageFilter {
}

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

class _DilateImageFilter implements ImageFilter {
Expand Down Expand Up @@ -3412,7 +3412,7 @@ class _DilateImageFilter implements ImageFilter {
}

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

class _ErodeImageFilter implements ImageFilter {
Expand Down Expand Up @@ -3471,7 +3471,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 @@ -4048,7 +4048,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 @@ -5508,7 +5508,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
10 changes: 2 additions & 8 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,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 @@ -2016,13 +2016,7 @@ class Locale {
}

@override
int get hashCode => _hashCode[this] ??= hashValues(
languageCode,
scriptCode,
countryCode == '' ? null : countryCode,
);
// Memoize hashCode since languageCode and countryCode require lookups.
static final Expando<int> _hashCode = Expando<int>();
int get hashCode => Object.hash(languageCode, scriptCode, countryCode == '' ? null : countryCode);

static Locale? _cachedLocale;
static String? _cachedLocaleString;
Expand Down
36 changes: 26 additions & 10 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,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 @@ -988,7 +988,7 @@ class FontVariation {
}

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

@override
String toString() => "FontVariation('$axis', $value)";
Expand Down Expand Up @@ -1236,7 +1236,7 @@ class TextHeightBehavior {

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

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

@override
String toString() {
Expand Down Expand Up @@ -1785,7 +1801,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 @@ -1979,7 +1995,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 @@ -2145,7 +2161,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 @@ -2252,7 +2268,7 @@ class TextPosition {
}

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

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

@override
int get hashCode => hashValues(
int get hashCode => Object.hash(
start.hashCode,
end.hashCode,
);
Expand Down Expand Up @@ -2619,7 +2635,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 @@ -983,7 +983,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
12 changes: 6 additions & 6 deletions lib/web_ui/lib/geometry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)})';
Expand Down Expand Up @@ -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)})';
Expand Down Expand Up @@ -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)})';
Expand Down Expand Up @@ -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)})';
Expand Down Expand Up @@ -374,7 +374,7 @@ class Radius {
}

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

@override
String toString() {
Expand Down Expand Up @@ -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);

Expand Down
Loading