Skip to content

Use TreeMap's ord implementation for Json #8312

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions src/libextra/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use std::to_str;

use serialize::Encodable;
use serialize;
use sort::Sort;
use treemap::TreeMap;

/// Represents a json value
Expand Down Expand Up @@ -1152,23 +1151,7 @@ impl Ord for Json {
Object(ref d0) => {
match *other {
Number(_) | String(_) | Boolean(_) | List(_) => false,
Object(ref d1) => {
let mut d0_flat = ~[];
let mut d1_flat = ~[];

// FIXME #4430: this is horribly inefficient...
for (k, v) in d0.iter() {
d0_flat.push((@(*k).clone(), @(*v).clone()));
}
d0_flat.qsort();

for (k, v) in d1.iter() {
d1_flat.push((@(*k).clone(), @(*v).clone()));
}
d1_flat.qsort();

d0_flat < d1_flat
}
Object(ref d1) => d0 < d1,
Null => true
}
}
Expand Down