@@ -284,6 +284,26 @@ VALUE string_spec_RSTRING_PTR_iterate(VALUE self, VALUE str) {
284
284
return Qnil ;
285
285
}
286
286
287
+ VALUE string_spec_RSTRING_PTR_iterate_uint32 (VALUE self , VALUE str ) {
288
+ int i ;
289
+ uint32_t * ptr ;
290
+ int l = RSTRING_LEN (str ) / sizeof (uint32_t );
291
+
292
+ ptr = (uint32_t * )RSTRING_PTR (str );
293
+ for (i = 0 ; i < l ; i ++ ) {
294
+ rb_yield (UINT2NUM (ptr [i ]));
295
+ }
296
+ return Qnil ;
297
+ }
298
+
299
+ VALUE string_spec_RSTRING_PTR_short_memcpy (VALUE self , VALUE str ) {
300
+ // Short memcpy operations may be optimised by the compiler to a single write.
301
+ if (RSTRING_LEN (str ) >= 8 ) {
302
+ memcpy (RSTRING_PTR (str ), "Infinity" , 8 );
303
+ }
304
+ return str ;
305
+ }
306
+
287
307
VALUE string_spec_RSTRING_PTR_assign (VALUE self , VALUE str , VALUE chr ) {
288
308
int i ;
289
309
char c ;
@@ -477,6 +497,8 @@ void Init_string_spec(void) {
477
497
rb_define_method (cls , "RSTRING_LEN" , string_spec_RSTRING_LEN , 1 );
478
498
rb_define_method (cls , "RSTRING_LENINT" , string_spec_RSTRING_LENINT , 1 );
479
499
rb_define_method (cls , "RSTRING_PTR_iterate" , string_spec_RSTRING_PTR_iterate , 1 );
500
+ rb_define_method (cls , "RSTRING_PTR_iterate_uint32" , string_spec_RSTRING_PTR_iterate_uint32 , 1 );
501
+ rb_define_method (cls , "RSTRING_PTR_short_memcpy" , string_spec_RSTRING_PTR_short_memcpy , 1 );
480
502
rb_define_method (cls , "RSTRING_PTR_assign" , string_spec_RSTRING_PTR_assign , 2 );
481
503
rb_define_method (cls , "RSTRING_PTR_set" , string_spec_RSTRING_PTR_set , 3 );
482
504
rb_define_method (cls , "RSTRING_PTR_after_funcall" , string_spec_RSTRING_PTR_after_funcall , 2 );
0 commit comments