From 53a6930e62a19aae608bfd980b329f293ddaf697 Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Tue, 15 Oct 2024 21:55:32 -0500 Subject: [PATCH] refactor: remove legacy equatable code --- lib/src/_data_class.dart | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/lib/src/_data_class.dart b/lib/src/_data_class.dart index fbb33d4..48c928c 100644 --- a/lib/src/_data_class.dart +++ b/lib/src/_data_class.dart @@ -6,41 +6,3 @@ final dataClassMacro = Uri.parse('package:data_class/src/_data_class.dart'); // Methods used in augmented code. const undefined = Object(); -final deepEquals = const DeepCollectionEquality().equals; - -// TODO(felangel): use jenkins hash from `package:equatable` -// once https://github.com/felangel/equatable/pull/174 is published. -/// Generate a hash for the provided [fields]. -int hashAll(Iterable? fields) { - return _finish(fields == null ? 0 : fields.fold(0, _combine)); -} - -int _combine(int hash, Object? object) { - if (object is Map) { - object.keys - .sorted((Object? a, Object? b) => a.hashCode - b.hashCode) - .forEach((Object? key) { - hash = hash ^ _combine(hash, [key, (object! as Map)[key]]); - }); - return hash; - } - if (object is Set) { - object = object.sorted((Object? a, Object? b) => a.hashCode - b.hashCode); - } - if (object is Iterable) { - for (final value in object) { - hash = hash ^ _combine(hash, value); - } - return hash ^ object.length; - } - - hash = 0x1fffffff & (hash + object.hashCode); - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); -} - -int _finish(int hash) { - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); -}