mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-23 06:12:00 +01:00
Pass a dummy isValidKey callback to normalized map and set
The default implementation runs a type check, which was a performance bottleneck when compiled to JS. There's no need for this type check in practice, since we never pass a non-String value to the contains(), containsKey(), or remove() methods (and if we do, it will throw a TypeError in our tests).
This commit is contained in:
parent
a841882724
commit
a8e99e9152
@ -306,7 +306,11 @@ bool startsWithIgnoreSeparator(String string, String prefix) {
|
|||||||
/// If [source] is passed, copies it into the map.
|
/// If [source] is passed, copies it into the map.
|
||||||
Map<String, V> normalizedMap<V>([Map<String, V> source]) {
|
Map<String, V> normalizedMap<V>([Map<String, V> source]) {
|
||||||
var map = LinkedHashMap<String, V>(
|
var map = LinkedHashMap<String, V>(
|
||||||
equals: equalsIgnoreSeparator, hashCode: hashCodeIgnoreSeparator);
|
// Explicitly set this because the default implementation involves a type
|
||||||
|
// check, which is very expensive in dart2js.
|
||||||
|
isValidKey: (_) => true,
|
||||||
|
equals: equalsIgnoreSeparator,
|
||||||
|
hashCode: hashCodeIgnoreSeparator);
|
||||||
if (source != null) map.addAll(source);
|
if (source != null) map.addAll(source);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -316,7 +320,11 @@ Map<String, V> normalizedMap<V>([Map<String, V> source]) {
|
|||||||
/// If [source] is passed, copies it into the set.
|
/// If [source] is passed, copies it into the set.
|
||||||
Set<String> normalizedSet([Iterable<String> source]) {
|
Set<String> normalizedSet([Iterable<String> source]) {
|
||||||
var set = LinkedHashSet(
|
var set = LinkedHashSet(
|
||||||
equals: equalsIgnoreSeparator, hashCode: hashCodeIgnoreSeparator);
|
// Explicitly set this because the default implementation involves a type
|
||||||
|
// check, which is very expensive in dart2js.
|
||||||
|
isValidKey: (_) => true,
|
||||||
|
equals: equalsIgnoreSeparator,
|
||||||
|
hashCode: hashCodeIgnoreSeparator);
|
||||||
if (source != null) set.addAll(source);
|
if (source != null) set.addAll(source);
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user