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
501f7ab2
Commit
501f7ab2
authored
Feb 25, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1738 from cubicdaiya/issues/optim_mrb_time_zone
small-optimization for mrb_time_zone
parents
ebd976be
96c24b0a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
mrbgems/mruby-time/src/time.c
mrbgems/mruby-time/src/time.c
+13
-6
No files found.
mrbgems/mruby-time/src/time.c
View file @
501f7ab2
...
...
@@ -93,11 +93,16 @@ enum mrb_timezone {
MRB_TIMEZONE_LAST
=
3
};
static
const
char
*
timezone_names
[]
=
{
"none"
,
"UTC"
,
"LOCAL"
,
NULL
typedef
struct
mrb_timezone_name
{
const
char
*
name
;
size_t
len
;
}
mrb_timezone_name
;
static
mrb_timezone_name
timezone_names
[]
=
{
{
"none"
,
sizeof
(
"none"
)
-
1
},
{
"UTC"
,
sizeof
(
"UTC"
)
-
1
},
{
"LOCAL"
,
sizeof
(
"LOCAL"
)
-
1
},
{
NULL
,
0
}
};
static
const
char
*
mon_names
[]
=
{
...
...
@@ -401,7 +406,9 @@ mrb_time_zone(mrb_state *mrb, mrb_value self)
tm
=
DATA_GET_PTR
(
mrb
,
self
,
&
mrb_time_type
,
struct
mrb_time
);
if
(
tm
->
timezone
<=
MRB_TIMEZONE_NONE
)
return
mrb_nil_value
();
if
(
tm
->
timezone
>=
MRB_TIMEZONE_LAST
)
return
mrb_nil_value
();
return
mrb_str_new_cstr
(
mrb
,
timezone_names
[
tm
->
timezone
]);
return
mrb_str_new_static
(
mrb
,
timezone_names
[
tm
->
timezone
].
name
,
timezone_names
[
tm
->
timezone
].
len
);
}
/* 15.2.19.7.4 */
...
...
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