16
16
fn ParseContext ::lex_decimal_integer (
17
17
ctx : ParseContext ,
18
18
start ~ : Int ,
19
- ) -> (Double , String ? ) raise ParseError {
19
+ ) -> (Double , StringView ? ) raise ParseError {
20
20
for {
21
21
match ctx .read_char () {
22
22
Some ('.' ) => return ctx .lex_decimal_point (start ~)
@@ -37,7 +37,7 @@ fn ParseContext::lex_decimal_integer(
37
37
fn ParseContext ::lex_decimal_point (
38
38
ctx : ParseContext ,
39
39
start ~ : Int ,
40
- ) -> (Double , String ? ) raise ParseError {
40
+ ) -> (Double , StringView ? ) raise ParseError {
41
41
match ctx .read_char () {
42
42
Some (c ) =>
43
43
if c >= '0' && c <= '9' {
@@ -53,7 +53,7 @@ fn ParseContext::lex_decimal_point(
53
53
fn ParseContext ::lex_decimal_fraction (
54
54
ctx : ParseContext ,
55
55
start ~ : Int ,
56
- ) -> (Double , String ? ) raise ParseError {
56
+ ) -> (Double , StringView ? ) raise ParseError {
57
57
for {
58
58
match ctx .read_char () {
59
59
Some ('e' | 'E' ) => return ctx .lex_decimal_exponent (start ~)
@@ -73,7 +73,7 @@ fn ParseContext::lex_decimal_fraction(
73
73
fn ParseContext ::lex_decimal_exponent (
74
74
ctx : ParseContext ,
75
75
start ~ : Int ,
76
- ) -> (Double , String ? ) raise ParseError {
76
+ ) -> (Double , StringView ? ) raise ParseError {
77
77
match ctx .read_char () {
78
78
Some ('+' ) | Some ('-' ) => return ctx .lex_decimal_exponent_sign (start ~)
79
79
Some (c ) => {
@@ -91,7 +91,7 @@ fn ParseContext::lex_decimal_exponent(
91
91
fn ParseContext ::lex_decimal_exponent_sign (
92
92
ctx : ParseContext ,
93
93
start ~ : Int ,
94
- ) -> (Double , String ? ) raise ParseError {
94
+ ) -> (Double , StringView ? ) raise ParseError {
95
95
match ctx .read_char () {
96
96
Some (c ) => {
97
97
if c >= '0' && c <= '9' {
@@ -108,7 +108,7 @@ fn ParseContext::lex_decimal_exponent_sign(
108
108
fn ParseContext ::lex_decimal_exponent_integer (
109
109
ctx : ParseContext ,
110
110
start ~ : Int ,
111
- ) -> (Double , String ? ) {
111
+ ) -> (Double , StringView ? ) {
112
112
for {
113
113
match ctx .read_char () {
114
114
Some (c ) => {
@@ -127,7 +127,7 @@ fn ParseContext::lex_decimal_exponent_integer(
127
127
fn ParseContext ::lex_zero (
128
128
ctx : ParseContext ,
129
129
start ~ : Int ,
130
- ) -> (Double , String ? ) raise ParseError {
130
+ ) -> (Double , StringView ? ) raise ParseError {
131
131
match ctx .read_char () {
132
132
Some ('.' ) => ctx .lex_decimal_point (start ~)
133
133
Some ('e' | 'E' ) => ctx .lex_decimal_exponent (start ~)
@@ -148,13 +148,8 @@ fn ParseContext::lex_number_end(
148
148
ctx : ParseContext ,
149
149
start : Int ,
150
150
end : Int ,
151
- ) -> (Double , String? ) {
152
- let s = ctx .input
153
- .data ()
154
- .unsafe_substring (
155
- start = ctx .input.start_offset () + start ,
156
- end = ctx .input.start_offset () + end ,
157
- )
151
+ ) -> (Double , StringView? ) {
152
+ let s = ctx .input.view (start_offset = start , end_offset = end )
158
153
if !s .contains ("." ) && !s .contains ("e" ) && !s .contains ("E" ) {
159
154
// If the string does not contain a decimal point or exponent, it is likely an integer
160
155
// We can try to parse it as an integer first
0 commit comments