|
|
|
|
|
by asQuirreL
851 days ago
|
|
There's no great mystery here, if you look at the internal function that's being called, it contains a TODO explaining that the code is unnecessarily quadratic and needs to be fixed: https://github.com/zed-industries/zed/blob/12b12ba17a380e321... So if selecting all matches requires calling this function for each match then I guess it's accidentally cubic? I also spotted two linear scans before this code (min by key and max by key). It seems like a combination of the implementation being inefficient even for what it was for (and that this was known), then it was used for something else in a naive way, and the use of a bad abstraction in the code base came at a performance cost. I don't think this is a case of Rust either demonstrating or failing to demonstrate zero-cost abstractions (at a language level). A language with zero-cost abstractions doesn't promise that any abstraction you write in it is magically going to be free, it just promises that when it makes a choice and abstracts that away from you, it is free (like with dynamic dispatch, or heap allocation, or destructors, or reference counting, etc). |
|