Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
32db0e5d
Commit
32db0e5d
authored
Apr 28, 2012
by
Yukihiro Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
struct RString member should not be mrb_value
parent
9e45eb18
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
include/mruby/string.h
include/mruby/string.h
+1
-1
src/gc.c
src/gc.c
+3
-2
src/string.c
src/string.c
+7
-7
No files found.
include/mruby/string.h
View file @
32db0e5d
...
...
@@ -29,7 +29,7 @@ struct RString {
long
len
;
union
{
size_t
capa
;
mrb_value
shared
;
struct
RString
*
shared
;
}
aux
;
char
*
buf
;
};
...
...
src/gc.c
View file @
32db0e5d
...
...
@@ -351,8 +351,9 @@ gc_mark_children(mrb_state *mrb, struct RBasic *obj)
{
struct
RString
*
s
=
(
struct
RString
*
)
obj
;
if
(
s
->
flags
&
MRB_STR_SHARED
)
{
mrb_gc_mark_value
(
mrb
,
s
->
aux
.
shared
)
while
(
s
->
flags
&
MRB_STR_SHARED
)
{
s
=
s
->
aux
.
shared
;
if
(
!
s
)
break
;
}
}
break
;
...
...
src/string.c
View file @
32db0e5d
...
...
@@ -492,13 +492,13 @@ str_new4(mrb_state *mrb, enum mrb_vtype ttype, mrb_value str)
RSTRING
(
str2
)
->
buf
=
RSTRING_PTR
(
str
);
if
(
MRB_STR_SHARED_P
(
str
))
{
mrb_value
shared
=
RSTRING_SHARED
(
str
);
struct
RString
*
shared
=
RSTRING_SHARED
(
str
);
FL_SET
(
str2
,
MRB_STR_SHARED
);
RSTRING_SHARED
(
str2
)
=
shared
;
}
else
{
FL_SET
(
str
,
MRB_STR_SHARED
);
RSTRING_SHARED
(
str
)
=
str2
;
RSTRING_SHARED
(
str
)
=
mrb_str_ptr
(
str2
)
;
}
mrb_enc_cr_str_exact_copy
(
mrb
,
str2
,
str
);
return
str2
;
...
...
@@ -2185,7 +2185,7 @@ str_replace_shared(mrb_state *mrb, mrb_value str2, mrb_value str)
str
=
mrb_str_new_frozen
(
mrb
,
str
);
RSTRING
(
str2
)
->
len
=
RSTRING_LEN
(
str
);
RSTRING
(
str2
)
->
buf
=
RSTRING_PTR
(
str
);
RSTRING_SHARED
(
str2
)
=
str
;
RSTRING_SHARED
(
str2
)
=
mrb_str_ptr
(
str
)
;
FL_SET
(
str2
,
MRB_STR_SHARED
);
mrb_enc_cr_str_exact_copy
(
mrb
,
str2
,
str
);
...
...
@@ -2220,9 +2220,9 @@ mrb_str_new_frozen(mrb_state *mrb, mrb_value orig)
klass
=
mrb_obj_class
(
mrb
,
orig
);
if
(
MRB_STR_SHARED_P
(
orig
)
&&
!
mrb_nil_p
(
RSTRING_SHARED
(
orig
)
))
{
if
(
MRB_STR_SHARED_P
(
orig
)
&&
RSTRING_SHARED
(
orig
))
{
long
ofs
;
ofs
=
RSTRING_LEN
(
str
)
-
RSTRING_
LEN
(
orig
)
;
ofs
=
RSTRING_LEN
(
str
)
-
RSTRING_
SHARED
(
orig
)
->
len
;
#ifdef INCLUDE_ENCODING
if
((
ofs
>
0
)
||
(
klass
!=
RBASIC
(
str
)
->
c
)
||
ENCODING_GET
(
mrb
,
str
)
!=
ENCODING_GET
(
mrb
,
orig
))
{
...
...
@@ -2776,9 +2776,9 @@ str_replace(mrb_state *mrb, mrb_value str, mrb_value str2)
len
=
RSTRING_LEN
(
str2
);
if
(
MRB_STR_SHARED_P
(
str2
))
{
mrb_value
shared
=
RSTRING_SHARED
(
str2
);
struct
RString
*
shared
=
RSTRING_SHARED
(
str2
);
RSTRING_LEN
(
str
)
=
len
;
RSTRING_PTR
(
str
)
=
RSTRING_PTR
(
str2
)
;
RSTRING_PTR
(
str
)
=
shared
->
buf
;
FL_SET
(
str
,
MRB_STR_SHARED
);
RSTRING_SHARED
(
str
)
=
shared
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment