-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In Ord instance in json, compare Objects more efficiently #4430
Comments
To save future reviewers time: the FIXME is referring to a loop for comparing two encoded JSON Objects (as opposed to Number, String, Boolean, Null, and List (aka "JSON Arrays")). Such Objects are represented as hashmaps. The comparison of two Objects is implemented by copying each hashmap to a There are potentially some interesting backwards-compatibility questions here; i.e. would we be willing to change the ordering defined by the above algorithm in order to have better overall performance. I assume the answer there is yes. Examples of some hacks that would change the ordering and improve performance (at least in special cases):
But since json.rs lives in libextra (and not the core), I am guessing that this does not mean that we need to worry about its backwards-compatibility. It would be good to clarify that, though. |
Another interesting idea that could happen here is to use a |
The fixme is still there and does all sorts of horrible things, but TreeMap is now used rather than HashMap. |
The default buffer size is the same as the one in Java's BufferedWriter. We may want BufferedWriter to have a Drop impl that flushes, but that isn't possible right now due to rust-lang#4252/rust-lang#4430. This would be a bit awkward due to the possibility of the inner flush failing. For what it's worth, Java's BufferedReader doesn't have a flushing finalizer, but that may just be because Java's finalizer support is awful. Closes rust-lang#8953
The default buffer size is the same as the one in Java's BufferedWriter. We may want BufferedWriter to have a Drop impl that flushes, but that isn't possible right now due to #4252/#4430. This would be a bit awkward due to the possibility of the inner flush failing. For what it's worth, Java's BufferedReader doesn't have a flushing finalizer, but that may just be because Java's finalizer support is awful. The current implementation of BufferedStream is weird in my opinion, but it's what the discussion in #8953 settled on. I wrote a custom copy function since vec::copy_from doesn't optimize as well as I would like. Closes #8953
as per a FIXME (formerly an XXX)
The text was updated successfully, but these errors were encountered: