File tree Expand file tree Collapse file tree 4 files changed +15
-10
lines changed
Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ impl Number {
4949 pub fn is_nan ( & self ) -> bool {
5050 self . category & NAN_MASK != 0
5151 }
52+
53+ #[ inline]
54+ pub fn is_empty ( & self ) -> bool {
55+ self . is_zero ( ) || self . is_nan ( )
56+ }
5257}
5358
5459impl PartialEq for Number {
Original file line number Diff line number Diff line change @@ -130,9 +130,9 @@ impl Node {
130130 }
131131
132132 // While `new` crates a fresh `Node` instance, it cannot do much about
133- // the `key_*` fields. In case of short keys that can be stored on the
134- // `Node` , only once the `Node` is somewhere on the heap, a persisting
135- // pointer to the key can be obtained .
133+ // the `key_*` fields. In the case a short key can be stored on the `Node`
134+ // itself , only once the `Node` is allocated on the heap can we obtain a
135+ // persisting pointer to it .
136136 #[ inline( always) ]
137137 fn attach_key ( & mut self , key : & [ u8 ] ) {
138138 if self . key_len <= KEY_BUF_LEN {
@@ -151,9 +151,9 @@ impl Node {
151151 }
152152 }
153153
154- // Since `Node`s are stored on a `Vec<Node>`, they will suffer from
155- // reallocation, changing `key_ptr` addresses for buffered keys. This
156- // needs to be called on each `Node` after each reallocation .
154+ // Since we store `Node`s on a vector, it will suffer from reallocation.
155+ // Whenever that happens, `key_ptr` for short keys will turn into dangling
156+ // pointers and will need to be re-cached .
157157 #[ inline( always) ]
158158 fn fix_key_ptr ( & mut self ) {
159159 if self . key_len <= KEY_BUF_LEN {
Original file line number Diff line number Diff line change @@ -260,7 +260,7 @@ macro_rules! allow_number_extensions {
260260 match $ch {
261261 b'.' => {
262262 $parser. bump( ) ;
263- expect_fracton !( $parser, $num, $e)
263+ expect_fraction !( $parser, $num, $e)
264264 } ,
265265 b'e' | b'E' => {
266266 $parser. bump( ) ;
@@ -284,7 +284,7 @@ macro_rules! allow_number_extensions {
284284
285285// If a dot `b"."` byte has been read, start reading the decimal fraction
286286// of the number.
287- macro_rules! expect_fracton {
287+ macro_rules! expect_fraction {
288288 ( $parser: ident, $num: ident, $e: ident) => ( {
289289 let result: Number ;
290290
@@ -632,7 +632,7 @@ impl<'a> Parser<'a> {
632632 } ,
633633 b'.' => {
634634 self . bump ( ) ;
635- return Ok ( expect_fracton ! ( self , num, e) ) ;
635+ return Ok ( expect_fraction ! ( self , num, e) ) ;
636636 } ,
637637 b'e' | b'E' => {
638638 self . bump ( ) ;
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ impl JsonValue {
112112 JsonValue :: Null => true ,
113113 JsonValue :: Short ( ref value) => value. is_empty ( ) ,
114114 JsonValue :: String ( ref value) => value. is_empty ( ) ,
115- JsonValue :: Number ( ref value) => value. is_zero ( ) ,
115+ JsonValue :: Number ( ref value) => value. is_empty ( ) ,
116116 JsonValue :: Boolean ( ref value) => !value,
117117 JsonValue :: Array ( ref value) => value. is_empty ( ) ,
118118 JsonValue :: Object ( ref value) => value. is_empty ( ) ,
You can’t perform that action at this time.
0 commit comments