Skip to content

Commit e9090eb

Browse files
peterzhu2118byroot
andcommitted
Remove unused code in time.c
Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
1 parent 08c2094 commit e9090eb

File tree

1 file changed

+4
-102
lines changed

1 file changed

+4
-102
lines changed

time.c

Lines changed: 4 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ static VALUE sym_hour, sym_min, sym_sec, sym_subsec, sym_dst, sym_zone;
6262
#define id_name idName
6363
#define UTC_ZONE Qundef
6464

65-
#ifndef TM_IS_TIME
66-
#define TM_IS_TIME 1
67-
#endif
68-
6965
#define NDIV(x,y) (-(-((x)+1)/(y))-1)
7066
#define NMOD(x,y) ((y)-(-((x)+1)%(y))-1)
7167
#define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d))
@@ -5546,7 +5542,6 @@ tm_from_time(VALUE klass, VALUE time)
55465542
{
55475543
struct time_object *tobj;
55485544
struct vtm vtm, *v;
5549-
#if TM_IS_TIME
55505545
VALUE tm;
55515546
struct time_object *ttm;
55525547

@@ -5562,29 +5557,6 @@ tm_from_time(VALUE klass, VALUE time)
55625557
ttm->tm_got = 1;
55635558
TZMODE_SET_UTC(ttm);
55645559
return tm;
5565-
#else
5566-
VALUE args[8];
5567-
int i = 0;
5568-
5569-
GetTimeval(time, tobj);
5570-
if (tobj->tm_got && TZMODE_UTC_P(tobj))
5571-
v = &tobj->vtm;
5572-
else
5573-
GMTIMEW(tobj->timew, v = &vtm);
5574-
args[i++] = v->year;
5575-
args[i++] = INT2FIX(v->mon);
5576-
args[i++] = INT2FIX(v->mday);
5577-
args[i++] = INT2FIX(v->hour);
5578-
args[i++] = INT2FIX(v->min);
5579-
args[i++] = INT2FIX(v->sec);
5580-
switch (v->isdst) {
5581-
case 0: args[i++] = Qfalse; break;
5582-
case 1: args[i++] = Qtrue; break;
5583-
default: args[i++] = Qnil; break;
5584-
}
5585-
args[i++] = w2v(rb_time_unmagnify(tobj->timew));
5586-
return rb_class_new_instance(i, args, klass);
5587-
#endif
55885560
}
55895561

55905562
/*
@@ -5604,23 +5576,10 @@ tm_initialize(int argc, VALUE *argv, VALUE tm)
56045576
if (rb_check_arity(argc, 1, 7) > 6) argc = 6;
56055577
time_arg(argc, argv, &vtm);
56065578
t = timegmw(&vtm);
5607-
{
5608-
#if TM_IS_TIME
5609-
struct time_object *tobj = DATA_PTR(tm);
5610-
TZMODE_SET_UTC(tobj);
5611-
tobj->timew = t;
5612-
tobj->vtm = vtm;
5613-
#else
5614-
int i = 0;
5615-
RSTRUCT_SET(tm, i++, INT2FIX(vtm.sec));
5616-
RSTRUCT_SET(tm, i++, INT2FIX(vtm.min));
5617-
RSTRUCT_SET(tm, i++, INT2FIX(vtm.hour));
5618-
RSTRUCT_SET(tm, i++, INT2FIX(vtm.mday));
5619-
RSTRUCT_SET(tm, i++, INT2FIX(vtm.mon));
5620-
RSTRUCT_SET(tm, i++, vtm.year);
5621-
RSTRUCT_SET(tm, i++, w2v(rb_time_unmagnify(t)));
5622-
#endif
5623-
}
5579+
struct time_object *tobj = DATA_PTR(tm);
5580+
TZMODE_SET_UTC(tobj);
5581+
tobj->timew = t;
5582+
tobj->vtm = vtm;
56245583
return tm;
56255584
}
56265585

@@ -5634,51 +5593,13 @@ tm_initialize(int argc, VALUE *argv, VALUE tm)
56345593
static VALUE
56355594
tm_to_time(VALUE tm)
56365595
{
5637-
#if TM_IS_TIME
56385596
struct time_object *torig = get_timeval(tm);
56395597
VALUE dup = time_s_alloc(rb_cTime);
56405598
struct time_object *tobj = DATA_PTR(dup);
56415599
*tobj = *torig;
56425600
return dup;
5643-
#else
5644-
VALUE t[6];
5645-
const VALUE *p = RSTRUCT_CONST_PTR(tm);
5646-
int i;
5647-
5648-
for (i = 0; i < numberof(t); ++i) {
5649-
t[i] = p[numberof(t) - 1 - i];
5650-
}
5651-
return time_s_mkutc(numberof(t), t, rb_cTime);
5652-
#endif
56535601
}
56545602

5655-
#if !TM_IS_TIME
5656-
static VALUE
5657-
tm_zero(VALUE tm)
5658-
{
5659-
return INT2FIX(0);
5660-
}
5661-
5662-
#define tm_subsec tm_zero
5663-
#define tm_utc_offset tm_zero
5664-
5665-
static VALUE
5666-
tm_isdst(VALUE tm)
5667-
{
5668-
return Qfalse;
5669-
}
5670-
5671-
static VALUE
5672-
tm_to_s(VALUE tm)
5673-
{
5674-
const VALUE *p = RSTRUCT_CONST_PTR(tm);
5675-
5676-
return rb_sprintf("%.4"PRIsVALUE"-%.2"PRIsVALUE"-%.2"PRIsVALUE" "
5677-
"%.2"PRIsVALUE":%.2"PRIsVALUE":%.2"PRIsVALUE" "
5678-
"UTC",
5679-
p[5], p[4], p[3], p[2], p[1], p[0]);
5680-
}
5681-
#else
56825603
static VALUE
56835604
tm_plus(VALUE tm, VALUE offset)
56845605
{
@@ -5690,14 +5611,12 @@ tm_minus(VALUE tm, VALUE offset)
56905611
{
56915612
return time_add0(rb_obj_class(tm), get_timeval(tm), tm, offset, -1);
56925613
}
5693-
#endif
56945614

56955615
static VALUE
56965616
Init_tm(VALUE outer, const char *name)
56975617
{
56985618
/* :stopdoc:*/
56995619
VALUE tm;
5700-
#if TM_IS_TIME
57015620
tm = rb_define_class_under(outer, name, rb_cObject);
57025621
rb_define_alloc_func(tm, time_s_alloc);
57035622
rb_define_method(tm, "sec", time_sec, 0);
@@ -5730,18 +5649,6 @@ Init_tm(VALUE outer, const char *name)
57305649
rb_define_method(tm, "to_r", time_to_r, 0);
57315650
rb_define_method(tm, "+", tm_plus, 1);
57325651
rb_define_method(tm, "-", tm_minus, 1);
5733-
#else
5734-
tm = rb_struct_define_under(outer, "tm",
5735-
"sec", "min", "hour",
5736-
"mday", "mon", "year",
5737-
"to_i", NULL);
5738-
rb_define_method(tm, "subsec", tm_subsec, 0);
5739-
rb_define_method(tm, "utc_offset", tm_utc_offset, 0);
5740-
rb_define_method(tm, "to_s", tm_to_s, 0);
5741-
rb_define_method(tm, "inspect", tm_to_s, 0);
5742-
rb_define_method(tm, "isdst", tm_isdst, 0);
5743-
rb_define_method(tm, "dst?", tm_isdst, 0);
5744-
#endif
57455652
rb_define_method(tm, "initialize", tm_initialize, -1);
57465653
rb_define_method(tm, "utc", tm_to_time, 0);
57475654
rb_alias(tm, rb_intern_const("to_time"), rb_intern_const("utc"));
@@ -5913,11 +5820,6 @@ Init_Time(void)
59135820
/* methods for marshaling */
59145821
rb_define_private_method(rb_cTime, "_dump", time_dump, -1);
59155822
rb_define_private_method(scTime, "_load", time_load, 1);
5916-
#if 0
5917-
/* Time will support marshal_dump and marshal_load in the future (1.9 maybe) */
5918-
rb_define_private_method(rb_cTime, "marshal_dump", time_mdump, 0);
5919-
rb_define_private_method(rb_cTime, "marshal_load", time_mload, 1);
5920-
#endif
59215823

59225824
if (debug_find_time_numguess) {
59235825
rb_define_hooked_variable("$find_time_numguess", (VALUE *)&find_time_numguess,

0 commit comments

Comments
 (0)