@@ -51,8 +51,7 @@ use std::collections::TreeMap;
5151use stats:: Stats ;
5252use getopts:: { OptGroup , optflag, optopt} ;
5353use regex:: Regex ;
54- use serialize:: { json, Decodable } ;
55- use serialize:: json:: { Json , ToJson } ;
54+ use serialize:: { json, Decodable , Encodable } ;
5655use term:: Terminal ;
5756use term:: color:: { Color , RED , YELLOW , GREEN , CYAN } ;
5857
@@ -1100,17 +1099,6 @@ fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult {
11001099 }
11011100}
11021101
1103-
1104- impl ToJson for Metric {
1105- fn to_json ( & self ) -> json:: Json {
1106- let mut map = TreeMap :: new ( ) ;
1107- map. insert ( "value" . to_string ( ) , json:: Json :: F64 ( self . value ) ) ;
1108- map. insert ( "noise" . to_string ( ) , json:: Json :: F64 ( self . noise ) ) ;
1109- json:: Json :: Object ( map)
1110- }
1111- }
1112-
1113-
11141102impl MetricMap {
11151103
11161104 pub fn new ( ) -> MetricMap {
@@ -1138,14 +1126,8 @@ impl MetricMap {
11381126 pub fn save ( & self , p : & Path ) -> io:: IoResult < ( ) > {
11391127 let mut file = try!( File :: create ( p) ) ;
11401128 let MetricMap ( ref map) = * self ;
1141-
1142- // FIXME(pcwalton): Yuck.
1143- let mut new_map = TreeMap :: new ( ) ;
1144- for ( ref key, ref value) in map. iter ( ) {
1145- new_map. insert ( key. to_string ( ) , ( * value) . clone ( ) ) ;
1146- }
1147-
1148- new_map. to_json ( ) . to_pretty_writer ( & mut file)
1129+ let mut enc = json:: PrettyEncoder :: new ( & mut file) ;
1130+ map. encode ( & mut enc)
11491131 }
11501132
11511133 /// Compare against another MetricMap. Optionally compare all
0 commit comments