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
0c52112d
Commit
0c52112d
authored
Aug 24, 2017
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep `Range` class in `mrb_state` structure for performance.
parent
04dbbff3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
include/mruby.h
include/mruby.h
+1
-0
src/range.c
src/range.c
+3
-4
No files found.
include/mruby.h
View file @
0c52112d
...
...
@@ -201,6 +201,7 @@ typedef struct mrb_state {
struct
RClass
*
string_class
;
struct
RClass
*
array_class
;
struct
RClass
*
hash_class
;
struct
RClass
*
range_class
;
struct
RClass
*
float_class
;
struct
RClass
*
fixnum_class
;
...
...
src/range.c
View file @
0c52112d
...
...
@@ -10,8 +10,6 @@
#include <mruby/string.h>
#include <mruby/array.h>
#define RANGE_CLASS (mrb_class_get(mrb, "Range"))
MRB_API
struct
RRange
*
mrb_range_ptr
(
mrb_state
*
mrb
,
mrb_value
v
)
{
...
...
@@ -50,7 +48,7 @@ mrb_range_new(mrb_state *mrb, mrb_value beg, mrb_value end, mrb_bool excl)
struct
RRange
*
r
;
range_check
(
mrb
,
beg
,
end
);
r
=
(
struct
RRange
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_RANGE
,
RANGE_CLASS
);
r
=
(
struct
RRange
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_RANGE
,
mrb
->
range_class
);
r
->
edges
=
(
mrb_range_edges
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_range_edges
));
r
->
edges
->
beg
=
beg
;
r
->
edges
->
end
=
end
;
...
...
@@ -353,7 +351,7 @@ range_eql(mrb_state *mrb, mrb_value range)
mrb_get_args
(
mrb
,
"o"
,
&
obj
);
if
(
mrb_obj_equal
(
mrb
,
range
,
obj
))
return
mrb_true_value
();
if
(
!
mrb_obj_is_kind_of
(
mrb
,
obj
,
RANGE_CLASS
))
{
if
(
!
mrb_obj_is_kind_of
(
mrb
,
obj
,
mrb
->
range_class
))
{
return
mrb_false_value
();
}
if
(
mrb_type
(
obj
)
!=
MRB_TT_RANGE
)
return
mrb_false_value
();
...
...
@@ -423,6 +421,7 @@ mrb_init_range(mrb_state *mrb)
struct
RClass
*
r
;
r
=
mrb_define_class
(
mrb
,
"Range"
,
mrb
->
object_class
);
/* 15.2.14 */
mrb
->
range_class
=
r
;
MRB_SET_INSTANCE_TT
(
r
,
MRB_TT_RANGE
);
mrb_define_method
(
mrb
,
r
,
"begin"
,
mrb_range_beg
,
MRB_ARGS_NONE
());
/* 15.2.14.4.3 */
...
...
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