@@ -202,10 +202,11 @@ function jsoo_is_ascii(s) {
202202//Provides: caml_bytes_unsafe_get mutable
203203function caml_bytes_unsafe_get ( s , i ) {
204204 switch ( s . t & 6 ) {
205- default : /* PARTIAL */
206- if ( i >= s . c . length ) return 0 ;
207205 case 0 /* BYTES */ :
208206 return s . c . charCodeAt ( i ) ;
207+ case 2 /* PARTIAL */ :
208+ if ( i >= s . c . length ) return 0 ;
209+ return s . c . charCodeAt ( i ) ;
209210 case 4 /* ARRAY */ :
210211 return s . c [ i ] ;
211212 }
@@ -442,17 +443,16 @@ function MlBytes(tag, contents, length) {
442443}
443444MlBytes . prototype . toString = function ( ) {
444445 switch ( this . t ) {
445- case 9 /*BYTES | ASCII*/ :
446+ case 9 : /*BYTES | ASCII*/
447+ case 8 /*BYTES | NOT_ASCII*/ :
446448 return this . c ;
447- default :
449+ case 4 : /* ARRAY */
450+ case 2 /* PARTIAL */ :
448451 caml_convert_string_to_bytes ( this ) ;
452+ //fallthrough
449453 case 0 /*BYTES | UNKOWN*/ :
450- if ( jsoo_is_ascii ( this . c ) ) {
451- this . t = 9 ; /*BYTES | ASCII*/
452- return this . c ;
453- }
454- this . t = 8 ; /*BYTES | NOT_ASCII*/
455- case 8 /*BYTES | NOT_ASCII*/ :
454+ if ( jsoo_is_ascii ( this . c ) ) this . t = 9 ; /*BYTES | ASCII*/
455+ else this . t = 8 ; /*BYTES | NOT_ASCII*/
456456 return this . c ;
457457 }
458458} ;
@@ -894,13 +894,13 @@ function caml_is_ml_bytes(s) {
894894
895895//Provides: caml_ml_bytes_content
896896//Requires: MlBytes, caml_convert_string_to_bytes
897+ //Returns a (full) string of bytes or an array
897898function caml_ml_bytes_content ( s ) {
898899 switch ( s . t & 6 ) {
899- default : /* PARTIAL */
900+ case 2 /* PARTIAL */ :
900901 caml_convert_string_to_bytes ( s ) ;
901- case 0 /* BYTES */ :
902- return s . c ;
903- case 4 :
902+ // fallthrough
903+ default : /* BYTES or ARRAY */
904904 return s . c ;
905905 }
906906}
0 commit comments