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
905fef26
Commit
905fef26
authored
Feb 05, 2019
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce invocation of `mrb_convert_type()` from `mrb_str_to_str()`.
parent
02fbb2c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
src/class.c
src/class.c
+1
-1
src/string.c
src/string.c
+12
-2
No files found.
src/class.c
View file @
905fef26
...
...
@@ -1815,7 +1815,7 @@ mrb_define_alias(mrb_state *mrb, struct RClass *klass, const char *name1, const
* show information on the thing we're attached to as well.
*/
static
mrb_value
mrb_value
mrb_mod_to_s
(
mrb_state
*
mrb
,
mrb_value
klass
)
{
mrb_value
str
;
...
...
src/string.c
View file @
905fef26
...
...
@@ -20,6 +20,7 @@
#include <mruby/class.h>
#include <mruby/range.h>
#include <mruby/string.h>
#include <mruby/numeric.h>
#include <mruby/re.h>
typedef
struct
mrb_shared_string
{
...
...
@@ -972,13 +973,22 @@ mrb_str_equal_m(mrb_state *mrb, mrb_value str1)
return
mrb_bool_value
(
mrb_str_equal
(
mrb
,
str1
,
str2
));
}
/* ---------------------------------- */
mrb_value
mrb_mod_to_s
(
mrb_state
*
mrb
,
mrb_value
klass
);
MRB_API
mrb_value
mrb_str_to_str
(
mrb_state
*
mrb
,
mrb_value
str
)
{
if
(
!
mrb_string_p
(
str
))
{
switch
(
mrb_type
(
str
))
{
case
MRB_TT_STRING
:
return
str
;
case
MRB_TT_FIXNUM
:
return
mrb_fixnum_to_str
(
mrb
,
str
,
10
);
case
MRB_TT_CLASS
:
case
MRB_TT_MODULE
:
return
mrb_mod_to_s
(
mrb
,
str
);
default:
return
mrb_convert_type
(
mrb
,
str
,
MRB_TT_STRING
,
"String"
,
"to_s"
);
}
return
str
;
}
MRB_API
const
char
*
...
...
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