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
08eafe21
Commit
08eafe21
authored
5 years ago
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement Ruby2.7's frozen strings from `Symbol#to_s`.
parent
264239f7
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
mrbgems/mruby-symbol-ext/mrblib/symbol.rb
mrbgems/mruby-symbol-ext/mrblib/symbol.rb
+4
-4
src/class.c
src/class.c
+1
-0
src/symbol.c
src/symbol.c
+7
-3
No files found.
mrbgems/mruby-symbol-ext/mrblib/symbol.rb
View file @
08eafe21
...
...
@@ -10,7 +10,7 @@ class Symbol
# Same as <code>sym.to_s.capitalize.intern</code>.
def
capitalize
(
self
.
to_s
.
capitalize!
||
self
)
.
to_sym
self
.
to_s
.
capitalize
.
to_sym
end
##
...
...
@@ -20,7 +20,7 @@ class Symbol
# Same as <code>sym.to_s.downcase.intern</code>.
def
downcase
(
self
.
to_s
.
downcase!
||
self
)
.
to_sym
self
.
to_s
.
downcase
.
to_sym
end
##
...
...
@@ -30,7 +30,7 @@ class Symbol
# Same as <code>sym.to_s.upcase.intern</code>.
def
upcase
(
self
.
to_s
.
upcase!
||
self
)
.
to_sym
self
.
to_s
.
upcase
.
to_sym
end
##
...
...
@@ -41,7 +41,7 @@ class Symbol
def
casecmp
(
other
)
return
nil
unless
other
.
kind_of?
(
Symbol
)
lhs
=
self
.
to_s
;
lhs
.
upcase!
lhs
=
self
.
to_s
.
upcase
rhs
=
other
.
to_s
.
upcase
lhs
<=>
rhs
end
...
...
This diff is collapsed.
Click to expand it.
src/class.c
View file @
08eafe21
...
...
@@ -72,6 +72,7 @@ mrb_class_name_class(mrb_state *mrb, struct RClass *outer, struct RClass *c, mrb
}
return
;
}
name
=
mrb_str_dup
(
mrb
,
name
);
mrb_str_cat_cstr
(
mrb
,
name
,
"::"
);
mrb_str_cat_cstr
(
mrb
,
name
,
mrb_sym_name
(
mrb
,
id
));
}
...
...
This diff is collapsed.
Click to expand it.
src/symbol.c
View file @
08eafe21
...
...
@@ -517,14 +517,18 @@ mrb_sym_str(mrb_state *mrb, mrb_sym sym)
{
mrb_int
len
;
const
char
*
name
=
mrb_sym_name_len
(
mrb
,
sym
,
&
len
);
mrb_value
str
;
if
(
!
name
)
return
mrb_undef_value
();
/* can't happen */
if
(
SYMBOL_INLINE_P
(
sym
))
{
mrb_value
str
=
mrb_str_new
(
mrb
,
name
,
len
);
str
=
mrb_str_new
(
mrb
,
name
,
len
);
RSTR_SET_ASCII_FLAG
(
mrb_str_ptr
(
str
));
return
str
;
}
return
mrb_str_new_static
(
mrb
,
name
,
len
);
else
{
str
=
mrb_str_new_static
(
mrb
,
name
,
len
);
}
MRB_SET_FROZEN_FLAG
(
mrb_str_ptr
(
str
));
return
str
;
}
static
const
char
*
...
...
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