File tree Expand file tree Collapse file tree 1 file changed +1
-31
lines changed Expand file tree Collapse file tree 1 file changed +1
-31
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ function build (schema, options) {
1515 `
1616 code += `
1717 ${ $asString . toString ( ) }
18- ${ $asStringSmall . toString ( ) }
1918 ${ $asNumber . toString ( ) }
2019 ${ $asNull . toString ( ) }
2120 ${ $asBoolean . toString ( ) }
@@ -85,36 +84,7 @@ function $asString (str) {
8584 str = str . toString ( )
8685 }
8786
88- if ( str . length < 42 ) {
89- return $asStringSmall ( str )
90- } else {
91- return JSON . stringify ( str )
92- }
93- }
94-
95- // magically escape strings for json
96- // relying on their charCodeAt
97- // everything below 32 needs JSON.stringify()
98- // 34 and 92 happens all the time, so we
99- // have a fast case for them
100- function $asStringSmall ( str ) {
101- var result = ''
102- var last = 0
103- var l = str . length
104- var point = 255
105- for ( var i = 0 ; i < l && point >= 32 ; i ++ ) {
106- point = str . charCodeAt ( i )
107- if ( point === 34 || point === 92 ) {
108- result += str . slice ( last , i ) + '\\' + str [ i ]
109- last = i + 1
110- }
111- }
112- if ( last === 0 ) {
113- result = str
114- } else {
115- result += str . slice ( last )
116- }
117- return point < 32 ? JSON . stringify ( str ) : '"' + result + '"'
87+ return JSON . stringify ( str )
11888}
11989
12090function $asRegExp ( reg ) {
You can’t perform that action at this time.
0 commit comments