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
1f5a7f2f
Commit
1f5a7f2f
authored
5 years ago
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Freeze strings from `nil.to_s`, `true.to_s`, `false.to_s`.
This is an experimental changes in Ruby 2.7.
parent
08eafe21
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
5 deletions
+18
-5
include/mruby.h
include/mruby.h
+6
-0
src/kernel.c
src/kernel.c
+1
-1
src/object.c
src/object.c
+4
-4
src/string.c
src/string.c
+7
-0
No files found.
include/mruby.h
View file @
1f5a7f2f
...
...
@@ -1022,6 +1022,12 @@ MRB_API mrb_value mrb_str_new_cstr(mrb_state*, const char*);
MRB_API
mrb_value
mrb_str_new_static
(
mrb_state
*
mrb
,
const
char
*
p
,
size_t
len
);
#define mrb_str_new_lit(mrb, lit) mrb_str_new_static(mrb, (lit), mrb_strlen_lit(lit))
MRB_API
mrb_value
mrb_obj_freeze
(
mrb_state
*
,
mrb_value
);
#define mrb_str_new_frozen(mrb,p,len) mrb_obj_freeze(mrb,mrb_str_new(mrb,p,len))
#define mrb_str_new_cstr_frozen(mrb,p) mrb_obj_freeze(mrb,mrb_str_new_cstr(mrb,p))
#define mrb_str_new_static_frozen(mrb,p,len) mrb_obj_freeze(mrb,mrb_str_new_static(mrb,p,len))
#define mrb_str_new_lit_frozen(mrb,lit) mrb_obj_freeze(mrb,mrb_str_new_lit(mrb,lit))
#ifdef _WIN32
MRB_API
char
*
mrb_utf8_from_locale
(
const
char
*
p
,
int
len
);
MRB_API
char
*
mrb_locale_from_utf8
(
const
char
*
p
,
int
len
);
...
...
This diff is collapsed.
Click to expand it.
src/kernel.c
View file @
1f5a7f2f
...
...
@@ -431,7 +431,7 @@ mrb_obj_extend_m(mrb_state *mrb, mrb_value self)
return
mrb_obj_extend
(
mrb
,
argc
,
argv
,
self
);
}
static
mrb_value
MRB_API
mrb_value
mrb_obj_freeze
(
mrb_state
*
mrb
,
mrb_value
self
)
{
if
(
!
mrb_immediate_p
(
self
))
{
...
...
This diff is collapsed.
Click to expand it.
src/object.c
View file @
1f5a7f2f
...
...
@@ -83,13 +83,13 @@ mrb_true(mrb_state *mrb, mrb_value obj)
static
mrb_value
nil_to_s
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
return
mrb_str_new
(
mrb
,
0
,
0
);
return
mrb_str_new
_frozen
(
mrb
,
0
,
0
);
}
static
mrb_value
nil_inspect
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
return
mrb_str_new_lit
(
mrb
,
"nil"
);
return
mrb_str_new_lit
_frozen
(
mrb
,
"nil"
);
}
/***********************************************************************
...
...
@@ -150,7 +150,7 @@ true_xor(mrb_state *mrb, mrb_value obj)
static
mrb_value
true_to_s
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
return
mrb_str_new_lit
(
mrb
,
"true"
);
return
mrb_str_new_lit
_frozen
(
mrb
,
"true"
);
}
/* 15.2.5.3.4 */
...
...
@@ -257,7 +257,7 @@ false_or(mrb_state *mrb, mrb_value obj)
static
mrb_value
false_to_s
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
return
mrb_str_new_lit
(
mrb
,
"false"
);
return
mrb_str_new_lit
_frozen
(
mrb
,
"false"
);
}
void
...
...
This diff is collapsed.
Click to expand it.
src/string.c
View file @
1f5a7f2f
...
...
@@ -235,6 +235,13 @@ mrb_str_new_static(mrb_state *mrb, const char *p, size_t len)
return
mrb_obj_value
(
s
);
}
MRB_API
mrb_value
mrb_str_freeze
(
mrb_state
*
mrb
,
const
char
*
p
,
size_t
len
)
{
struct
RString
*
s
=
str_new_static
(
mrb
,
p
,
len
);
return
mrb_obj_value
(
s
);
}
static
void
str_decref
(
mrb_state
*
mrb
,
mrb_shared_string
*
shared
)
{
...
...
This diff is collapsed.
Click to expand it.
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