Skip to content

Commit 06602bd

Browse files
author
Mike Dirolf
committed
clean up C ext Time handling
1 parent 7702d67 commit 06602bd

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

ext/cbson/cbson.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
#define MAX_HOSTNAME_LENGTH 256
7474

7575
static VALUE Binary;
76-
static VALUE Time;
7776
static VALUE ObjectID;
7877
static VALUE ObjectId;
7978
static VALUE DBRef;
@@ -708,12 +707,9 @@ static VALUE get_value(const char* buffer, int* position, int type) {
708707
case 9:
709708
{
710709
long long millis;
711-
VALUE seconds, microseconds;
712710
memcpy(&millis, buffer + *position, 8);
713-
seconds = LL2NUM(millis / 1000);
714-
microseconds = INT2NUM((millis % 1000) * 1000);
715711

716-
value = rb_funcall(Time, rb_intern("at"), 2, seconds, microseconds);
712+
value = rb_time_new(millis / 1000, (millis % 1000) * 1000);
717713
value = rb_funcall(value, rb_intern("utc"), 0);
718714
*position += 8;
719715
break;
@@ -914,7 +910,6 @@ static VALUE objectid_generate(VALUE self)
914910

915911
void Init_cbson() {
916912
VALUE bson, CBson, Digest, ext_version;
917-
Time = rb_const_get(rb_cObject, rb_intern("Time"));
918913

919914
bson = rb_const_get(rb_cObject, rb_intern("BSON"));
920915
rb_require("bson/types/binary");

0 commit comments

Comments
 (0)