Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7dca2e54
Unverified
Commit
7dca2e54
authored
Mar 16, 2021
by
Tong Mu
Committed by
GitHub
Mar 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Impl (#78218)
parent
4266d629
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
17 deletions
+11
-17
shortcuts.dart
packages/flutter/lib/src/widgets/shortcuts.dart
+11
-17
No files found.
packages/flutter/lib/src/widgets/shortcuts.dart
View file @
7dca2e54
...
...
@@ -26,6 +26,7 @@ import 'inherited_notifier.dart';
///
/// * [ShortcutManager], which uses [LogicalKeySet] (a [KeySet] subclass) to
/// define its key map.
@immutable
class
KeySet
<
T
extends
KeyboardKey
>
{
/// A constructor for making a [KeySet] of up to four keys.
///
...
...
@@ -81,7 +82,6 @@ class KeySet<T extends KeyboardKey> {
final
HashSet
<
T
>
_keys
;
@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes, to remove in NNBD with a late final hashcode
bool
operator
==(
Object
other
)
{
if
(
other
.
runtimeType
!=
runtimeType
)
{
return
false
;
...
...
@@ -90,25 +90,19 @@ class KeySet<T extends KeyboardKey> {
&&
setEquals
<
T
>(
other
.
_keys
,
_keys
);
}
// Arrays used to temporarily store hash codes for sorting.
static
final
List
<
int
>
_tempHashStore3
=
<
int
>[
0
,
0
,
0
];
// used to sort exactly 3 keys
static
final
List
<
int
>
_tempHashStore4
=
<
int
>[
0
,
0
,
0
,
0
];
// used to sort exactly 4 keys
// Cached hash code value. Improves [hashCode] performance by 27%-900%,
// depending on key set size and read/write ratio.
int
?
_hashCode
;
@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes, to remove in NNBD with a late final hashcode
int
get
hashCode
{
// Return cached hash code if available.
if
(
_hashCode
!=
null
)
{
return
_hashCode
!;
}
late
final
int
hashCode
=
_computeHashCode
(
_keys
);
// Arrays used to temporarily store hash codes for sorting.
static
final
List
<
int
>
_tempHashStore3
=
<
int
>[
0
,
0
,
0
];
// used to sort exactly 3 keys
static
final
List
<
int
>
_tempHashStore4
=
<
int
>[
0
,
0
,
0
,
0
];
// used to sort exactly 4 keys
static
int
_computeHashCode
<
T
>(
Set
<
T
>
keys
)
{
// Compute order-independent hash and cache it.
final
int
length
=
_
keys
.
length
;
final
Iterator
<
T
>
iterator
=
_
keys
.
iterator
;
final
int
length
=
keys
.
length
;
final
Iterator
<
T
>
iterator
=
keys
.
iterator
;
// There's always at least one key. Just extract it.
iterator
.
moveNext
();
...
...
@@ -116,14 +110,14 @@ class KeySet<T extends KeyboardKey> {
if
(
length
==
1
)
{
// Don't do anything fancy if there's exactly one key.
return
_hashCode
=
h1
;
return
h1
;
}
iterator
.
moveNext
();
final
int
h2
=
iterator
.
current
.
hashCode
;
if
(
length
==
2
)
{
// No need to sort if there's two keys, just compare them.
return
_hashCode
=
h1
<
h2
return
h1
<
h2
?
hashValues
(
h1
,
h2
)
:
hashValues
(
h2
,
h1
);
}
...
...
@@ -142,7 +136,7 @@ class KeySet<T extends KeyboardKey> {
sortedHashes
[
3
]
=
iterator
.
current
.
hashCode
;
}
sortedHashes
.
sort
();
return
_hashCode
=
hashList
(
sortedHashes
);
return
hashList
(
sortedHashes
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment