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
09bb3087
Commit
09bb3087
authored
Jan 02, 2014
by
cremno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tiny word boxing optimization
parent
e8dd8180
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
20 deletions
+13
-20
include/mruby/value.h
include/mruby/value.h
+1
-0
mrbgems/mruby-range-ext/src/range.c
mrbgems/mruby-range-ext/src/range.c
+2
-6
src/array.c
src/array.c
+2
-2
src/codegen.c
src/codegen.c
+1
-1
src/object.c
src/object.c
+3
-3
src/range.c
src/range.c
+3
-7
src/string.c
src/string.c
+1
-1
No files found.
include/mruby/value.h
View file @
09bb3087
...
@@ -315,6 +315,7 @@ mrb_float_value(struct mrb_state *mrb, mrb_float f)
...
@@ -315,6 +315,7 @@ mrb_float_value(struct mrb_state *mrb, mrb_float f)
#define mrb_bool(o) ((o).w != MRB_Qnil && (o).w != MRB_Qfalse)
#define mrb_bool(o) ((o).w != MRB_Qnil && (o).w != MRB_Qfalse)
#else
#else
#define mrb_cptr(o) mrb_ptr(o)
#define mrb_cptr(o) mrb_ptr(o)
#define mrb_fixnum_p(o) (mrb_type(o) == MRB_TT_FIXNUM)
#define mrb_fixnum_p(o) (mrb_type(o) == MRB_TT_FIXNUM)
#define mrb_undef_p(o) (mrb_type(o) == MRB_TT_UNDEF)
#define mrb_undef_p(o) (mrb_type(o) == MRB_TT_UNDEF)
...
...
mrbgems/mruby-range-ext/src/range.c
View file @
09bb3087
...
@@ -7,7 +7,7 @@ r_le(mrb_state *mrb, mrb_value a, mrb_value b)
...
@@ -7,7 +7,7 @@ r_le(mrb_state *mrb, mrb_value a, mrb_value b)
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
/* compare result */
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
/* compare result */
/* output :a < b => -1, a = b => 0, a > b => +1 */
/* output :a < b => -1, a = b => 0, a > b => +1 */
if
(
mrb_
type
(
r
)
==
MRB_TT_FIXNUM
)
{
if
(
mrb_
fixnum_p
(
r
)
)
{
mrb_int
c
=
mrb_fixnum
(
r
);
mrb_int
c
=
mrb_fixnum
(
r
);
if
(
c
==
0
||
c
==
-
1
)
return
TRUE
;
if
(
c
==
0
||
c
==
-
1
)
return
TRUE
;
}
}
...
@@ -21,11 +21,7 @@ r_lt(mrb_state *mrb, mrb_value a, mrb_value b)
...
@@ -21,11 +21,7 @@ r_lt(mrb_state *mrb, mrb_value a, mrb_value b)
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
/* output :a < b => -1, a = b => 0, a > b => +1 */
/* output :a < b => -1, a = b => 0, a > b => +1 */
if
(
mrb_type
(
r
)
==
MRB_TT_FIXNUM
)
{
return
mrb_fixnum_p
(
r
)
&&
mrb_fixnum
(
r
)
==
-
1
;
if
(
mrb_fixnum
(
r
)
==
-
1
)
return
TRUE
;
}
return
FALSE
;
}
}
/*
/*
...
...
src/array.c
View file @
09bb3087
...
@@ -318,7 +318,7 @@ mrb_ary_cmp(mrb_state *mrb, mrb_value ary1)
...
@@ -318,7 +318,7 @@ mrb_ary_cmp(mrb_state *mrb, mrb_value ary1)
for
(
i
=
0
;
i
<
len
;
i
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
mrb_value
v
=
ary_elt
(
ary2
,
i
);
mrb_value
v
=
ary_elt
(
ary2
,
i
);
r
=
mrb_funcall_argv
(
mrb
,
ary_elt
(
ary1
,
i
),
cmp
,
1
,
&
v
);
r
=
mrb_funcall_argv
(
mrb
,
ary_elt
(
ary1
,
i
),
cmp
,
1
,
&
v
);
if
(
mrb_type
(
r
)
!=
MRB_TT_FIXNUM
||
mrb_fixnum
(
r
)
!=
0
)
return
r
;
if
(
!
mrb_fixnum_p
(
r
)
||
mrb_fixnum
(
r
)
!=
0
)
return
r
;
}
}
}
}
len
=
a1
->
len
-
a2
->
len
;
len
=
a1
->
len
-
a2
->
len
;
...
@@ -697,7 +697,7 @@ mrb_ary_aget(mrb_state *mrb, mrb_value self)
...
@@ -697,7 +697,7 @@ mrb_ary_aget(mrb_state *mrb, mrb_value self)
return
mrb_ary_ref
(
mrb
,
self
,
index
);
return
mrb_ary_ref
(
mrb
,
self
,
index
);
case
1
:
case
1
:
if
(
mrb_type
(
argv
[
0
])
!=
MRB_TT_FIXNUM
)
{
if
(
!
mrb_fixnum_p
(
argv
[
0
])
)
{
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"expected Fixnum"
);
mrb_raise
(
mrb
,
E_TYPE_ERROR
,
"expected Fixnum"
);
}
}
if
(
index
<
0
)
index
+=
a
->
len
;
if
(
index
<
0
)
index
+=
a
->
len
;
...
...
src/codegen.c
View file @
09bb3087
...
@@ -421,7 +421,7 @@ new_lit(codegen_scope *s, mrb_value val)
...
@@ -421,7 +421,7 @@ new_lit(codegen_scope *s, mrb_value val)
case
MRB_TT_FIXNUM
:
case
MRB_TT_FIXNUM
:
for
(
i
=
0
;
i
<
s
->
irep
->
plen
;
i
++
)
{
for
(
i
=
0
;
i
<
s
->
irep
->
plen
;
i
++
)
{
pv
=
&
s
->
irep
->
pool
[
i
];
pv
=
&
s
->
irep
->
pool
[
i
];
if
(
mrb_type
(
*
pv
)
!=
MRB_TT_FIXNUM
)
continue
;
if
(
!
mrb_fixnum_p
(
*
pv
)
)
continue
;
if
(
mrb_fixnum
(
*
pv
)
==
mrb_fixnum
(
val
))
return
i
;
if
(
mrb_fixnum
(
*
pv
)
==
mrb_fixnum
(
val
))
return
i
;
}
}
break
;
break
;
...
...
src/object.c
View file @
09bb3087
...
@@ -326,9 +326,9 @@ mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method)
...
@@ -326,9 +326,9 @@ mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method)
{
{
mrb_value
v
;
mrb_value
v
;
if
(
mrb_
type
(
val
)
==
MRB_TT_FIXNUM
)
return
val
;
if
(
mrb_
fixnum_p
(
val
)
)
return
val
;
v
=
convert_type
(
mrb
,
val
,
"Integer"
,
method
,
FALSE
);
v
=
convert_type
(
mrb
,
val
,
"Integer"
,
method
,
FALSE
);
if
(
mrb_nil_p
(
v
)
||
mrb_type
(
v
)
!=
MRB_TT_FIXNUM
)
{
if
(
mrb_nil_p
(
v
)
||
!
mrb_fixnum_p
(
v
)
)
{
return
mrb_nil_value
();
return
mrb_nil_value
();
}
}
return
v
;
return
v
;
...
@@ -404,7 +404,7 @@ mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t)
...
@@ -404,7 +404,7 @@ mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t)
if
(
mrb_nil_p
(
x
))
{
if
(
mrb_nil_p
(
x
))
{
etype
=
"nil"
;
etype
=
"nil"
;
}
}
else
if
(
mrb_
type
(
x
)
==
MRB_TT_FIXNUM
)
{
else
if
(
mrb_
fixnum_p
(
x
)
)
{
etype
=
"Fixnum"
;
etype
=
"Fixnum"
;
}
}
else
if
(
mrb_type
(
x
)
==
MRB_TT_SYMBOL
)
{
else
if
(
mrb_type
(
x
)
==
MRB_TT_SYMBOL
)
{
...
...
src/range.c
View file @
09bb3087
...
@@ -176,7 +176,7 @@ r_le(mrb_state *mrb, mrb_value a, mrb_value b)
...
@@ -176,7 +176,7 @@ r_le(mrb_state *mrb, mrb_value a, mrb_value b)
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
/* compare result */
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
/* compare result */
/* output :a < b => -1, a = b => 0, a > b => +1 */
/* output :a < b => -1, a = b => 0, a > b => +1 */
if
(
mrb_
type
(
r
)
==
MRB_TT_FIXNUM
)
{
if
(
mrb_
fixnum_p
(
r
)
)
{
mrb_int
c
=
mrb_fixnum
(
r
);
mrb_int
c
=
mrb_fixnum
(
r
);
if
(
c
==
0
||
c
==
-
1
)
return
TRUE
;
if
(
c
==
0
||
c
==
-
1
)
return
TRUE
;
}
}
...
@@ -190,11 +190,7 @@ r_gt(mrb_state *mrb, mrb_value a, mrb_value b)
...
@@ -190,11 +190,7 @@ r_gt(mrb_state *mrb, mrb_value a, mrb_value b)
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
/* output :a < b => -1, a = b => 0, a > b => +1 */
/* output :a < b => -1, a = b => 0, a > b => +1 */
if
(
mrb_type
(
r
)
==
MRB_TT_FIXNUM
)
{
return
mrb_fixnum_p
(
r
)
&&
mrb_fixnum
(
r
)
==
1
;
if
(
mrb_fixnum
(
r
)
==
1
)
return
TRUE
;
}
return
FALSE
;
}
}
static
mrb_bool
static
mrb_bool
...
@@ -203,7 +199,7 @@ r_ge(mrb_state *mrb, mrb_value a, mrb_value b)
...
@@ -203,7 +199,7 @@ r_ge(mrb_state *mrb, mrb_value a, mrb_value b)
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
/* compare result */
mrb_value
r
=
mrb_funcall
(
mrb
,
a
,
"<=>"
,
1
,
b
);
/* compare result */
/* output :a < b => -1, a = b => 0, a > b => +1 */
/* output :a < b => -1, a = b => 0, a > b => +1 */
if
(
mrb_
type
(
r
)
==
MRB_TT_FIXNUM
)
{
if
(
mrb_
fixnum_p
(
r
)
)
{
mrb_int
c
=
mrb_fixnum
(
r
);
mrb_int
c
=
mrb_fixnum
(
r
);
if
(
c
==
0
||
c
==
1
)
return
TRUE
;
if
(
c
==
0
||
c
==
1
)
return
TRUE
;
}
}
...
...
src/string.c
View file @
09bb3087
...
@@ -1248,7 +1248,7 @@ mrb_str_include(mrb_state *mrb, mrb_value self)
...
@@ -1248,7 +1248,7 @@ mrb_str_include(mrb_state *mrb, mrb_value self)
mrb_bool
include_p
;
mrb_bool
include_p
;
mrb_get_args
(
mrb
,
"o"
,
&
str2
);
mrb_get_args
(
mrb
,
"o"
,
&
str2
);
if
(
mrb_
type
(
str2
)
==
MRB_TT_FIXNUM
)
{
if
(
mrb_
fixnum_p
(
str2
)
)
{
include_p
=
(
memchr
(
RSTRING_PTR
(
self
),
mrb_fixnum
(
str2
),
RSTRING_LEN
(
self
))
!=
NULL
);
include_p
=
(
memchr
(
RSTRING_PTR
(
self
),
mrb_fixnum
(
str2
),
RSTRING_LEN
(
self
))
!=
NULL
);
}
}
else
{
else
{
...
...
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