2 ms·
For OP's specific case, wouldn't it be better to just special case the compiler to detect that it is a large vector, and pick the same datatype for all elements
by londons_explore 3y ago
For OP's specific case, wouldn't it be better to just special case the compiler to detect that it is a large vector, and pick the same datatype for all elements of the vector? Suddenly an exponential search becomes linear.
- stonemetal12 3y agoYou would think the part of the compiler that parses integer literals would assign them the type integer, making this close to a no op for the type checker.
- slavapestov 3y agoNot the case when you have polymorphic literals, like in Swift or Haskell: let x: Int = 123 let y: Double = 123 But it looks like here the problem was not the type checker anyway.