dash icon indicating copy to clipboard operation
dash copied to clipboard

Stop using `Any` (where possible)

Open y21 opened this issue 2 years ago • 0 comments

std::any::TypeId will be (is, on nightly) 128 bits, to mitigate collisions (iiuc). I'm not sure if this will have a perf impact (I've seen u128 be significantly slower than u64 in specific benchmarks, probably because it's emulated using two u64s), but we should move away from it if at all possible. It also doesn't fully fix the issue: collisions are still possible, just far less likely than they already were with a u64. We currently use it a lot to, for example, downcast an object to specific object types to access "internal" object state (e.g. underlying buffer of an ArrayBuffer). We alread have a BuiltinCapable trait that we can add methods like as_arraybuffer and that should allow us to get rid of most instances. We probably can't fully get rid of it because external crates can define their own object types and store custom stuff in them that they may want to cast JS objects to, so we need to keep it, but we should avoid using it in dash itself

y21 avatar Jun 29 '23 14:06 y21