Skip to content

Commit

Permalink
add rb_str_new_frozen() and rb_str_dup_frozen()
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Dec 30, 2011
1 parent 1a7418b commit 283dd82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/ruby/intern.h
Expand Up @@ -490,6 +490,7 @@ VALUE rb_str_format(int, const VALUE *, VALUE);
VALUE rb_str_new(const char*, long);
VALUE rb_str_new2(const char*);
VALUE rb_str_new3(VALUE);
VALUE rb_str_new_frozen(VALUE);
VALUE rb_str_new4(VALUE);
VALUE rb_str_new5(VALUE, const char*, long);
VALUE rb_tainted_str_new(const char*, long);
Expand Down
15 changes: 15 additions & 0 deletions string.c
Expand Up @@ -6393,6 +6393,15 @@ rb_str_new5(VALUE source, const char *cstr, long len)
return (VALUE)str;
}

VALUE
rb_str_new_frozen(VALUE orig)
{
if (OBJ_FROZEN(orig)) {
return orig;
}
return rb_str_new4(orig);
}

VALUE
rb_str_tmp_new(long len)
{
Expand Down Expand Up @@ -6921,6 +6930,12 @@ rb_str_freeze(VALUE str)
return rb_obj_freeze(str);
}

VALUE
rb_str_dup_frozen(VALUE orig)
{
return rb_str_new_frozen(orig);
}

VALUE
rb_str_plus(VALUE str1, VALUE str2)
{
Expand Down

0 comments on commit 283dd82

Please sign in to comment.