0002-Expose-whether-two-arrays-are-shared-read-only-C-onl.patch

Patch 2 - add rb_ary_shared_with_p() - Greg Price, 10/14/2012 01:56 PM

Download (2.15 KB)

View differences:

ChangeLog
1
Tue Sep  4 14:16:52 2012  Greg Price  <price@mit.edu>
2

  
3
	* array.c (rb_ary_shared_with_p): new function.
4

  
5
	* include/ruby/intern.h (rb_ary_shared_with_p): declare.
6

  
1 7
Tue Sep  4 14:13:51 2012  Greg Price  <price@mit.edu>
2 8

  
3 9
	* load.c (loaded_feature_path): clarify and briefly comment
array.c
305 305
    return Qfalse;
306 306
}
307 307

  
308
/* This can be used to take a snapshot of an array (with
309
   e.g. rb_ary_replace) and check later whether the array has been
310
   modified from the snapshot.  The snapshot is cheap, though if
311
   something does modify the array it will pay the cost of copying
312
   it. */
313
VALUE
314
rb_ary_shared_with_p(VALUE ary1, VALUE ary2)
315
{
316
    if (!ARY_EMBED_P(ary1) && ARY_SHARED_P(ary1)
317
     && !ARY_EMBED_P(ary2) && ARY_SHARED_P(ary2)
318
     && RARRAY(ary1)->as.heap.aux.shared == RARRAY(ary2)->as.heap.aux.shared) {
319
	return Qtrue;
320
    }
321
    return Qfalse;
322
}
323

  
308 324
static VALUE
309 325
ary_alloc(VALUE klass)
310 326
{
include/ruby/intern.h
57 57
void rb_ary_free(VALUE);
58 58
void rb_ary_modify(VALUE);
59 59
VALUE rb_ary_freeze(VALUE);
60
VALUE rb_ary_shared_with_p(VALUE, VALUE);
60 61
VALUE rb_ary_aref(int, VALUE*, VALUE);
61 62
VALUE rb_ary_subseq(VALUE, long, long);
62 63
void rb_ary_store(VALUE, long, VALUE);
63
-