Comments (5)
@rebaz94 Dart does not require String
instances to be globally canonicalized (with some exceptions around compile time constants). This means two strings can be equal but not identical (because they are represented by different objects).
Simple example:
void main() {
final s0 = 'key1';
final s1 = 'key1,key2'.split(',').first;
print(s0 == s1);
print(identical(s0, s1));
}
This means using LinkedHashMap<String, ...>.identity()
is not a good idea (it is a map which uses key identity rather than equality) unless you somehow ensure canonicalization (e.g. you have another Map<String, String>
somewhere which stores canonical instances).
from sdk.
Edit: Ah, it was a movie, not a picture. Makes more sense now.
That does look suspicious, almost as if the hash table has been built using the wrong hash numbers.
(That said, a Map
's keys.contains
should work exactly the same as containsKey
, so getting a different result is itself a sign of something not being correct. Quoting the keys
documentation:
The returned iterable has efficient length and contains operations, based on
length
andcontainsKey
of the map.
So something is off.)
from sdk.
sorry for bad example, This code snippet just an example how I utilized the map. please check the video
final LinkedHashMap<String, dynamic> data = LinkedHashMap.identity(); print(data['key1']); // returns null print(data.containsKey('key1')); // returns false print(data.keys.contains(id)); // returns true
from sdk.
Ah, got it. Thank you for the clarification.
from sdk.
I'm still worried that .keys.contains
does not answer the same as .containsKey
. That suggests that .keys.contains
is probably also not efficient. The documentation for keys
states that it must have efficient contains
(fx. backed by the map's containsKey
.)
from sdk.
Related Issues (20)
- pkg/json breaks when a field name contains $ HOT 2
- [vm/ffi] `Pointer.asTypedList` shared across isolates causes use after free
- WASM incorrectly advertises dart.library.js HOT 2
- CFE fails to notice record field name differences when performing subtype matches HOT 1
- extension type on a Function named call HOT 7
- Invalid fixes being suggested
- Add a fix to create an extension method
- How should I load JS libraries from within WASM? HOT 2
- Macros: Failure to compile redirecting factories HOT 2
- [resource_identifiers] Rename to recorded_references. HOT 1
- [native_assets][resource_identifiers] Deferred loading and assets HOT 2
- Dart WebSocket Connection to webserver Exhibits Inconsistent Behavior and Premature Closure HOT 3
- JsonCodable macro field names HOT 3
- Support `environment` parameter for `Isolate.spawnUri` HOT 7
- Switch to RBE broke tools/generate_idefiles.py and compile_commands.json HOT 1
- Consider `EXTRANEOUS_MODIFIER` diagnostic improvements
- Dart LSP re-analyzes project when typing starts after period of inactivity HOT 6
- Move `Listenable`, `ValueListenable`, `ChangeNotifier` and `ValueNotifier` to the Dart sdk and add listening methods HOT 22
- Erroneous RangeError when compiling to WASM HOT 5
- [CP] [ CLI ] Fix DART_VM_OPTIONS usage only resulting in printing of help message HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.