[前][次][番号順一覧][スレッド一覧]

ruby-changes:67224

From: S-H-GAMELINKS <ko1@a...>
Date: Tue, 24 Aug 2021 09:23:22 +0900 (JST)
Subject: [ruby-changes:67224] 4794a8a7cf (master): Add stat_time function

https://git.ruby-lang.org/ruby.git/commit/?id=4794a8a7cf

From 4794a8a7cf4c9da00728e691b81dadb103383108 Mon Sep 17 00:00:00 2001
From: S-H-GAMELINKS <gamelinks007@g...>
Date: Mon, 23 Aug 2021 21:24:31 +0900
Subject: Add stat_time function

---
 file.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/file.c b/file.c
index 41ebf86..eb10c54 100644
--- a/file.c
+++ b/file.c
@@ -886,12 +886,17 @@ stat_atimespec(const struct stat *st) https://github.com/ruby/ruby/blob/trunk/file.c#L886
 }
 
 static VALUE
-stat_atime(const struct stat *st)
+stat_time(const struct timespec ts)
 {
-    struct timespec ts = stat_atimespec(st);
     return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
 }
 
+static VALUE
+stat_atime(const struct stat *st)
+{
+    return stat_time(stat_atimespec(st));
+}
+
 static struct timespec
 stat_mtimespec(const struct stat *st)
 {
@@ -912,8 +917,7 @@ stat_mtimespec(const struct stat *st) https://github.com/ruby/ruby/blob/trunk/file.c#L917
 static VALUE
 stat_mtime(const struct stat *st)
 {
-    struct timespec ts = stat_mtimespec(st);
-    return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
+    return stat_time(stat_mtimespec(st));
 }
 
 static struct timespec
@@ -936,8 +940,7 @@ stat_ctimespec(const struct stat *st) https://github.com/ruby/ruby/blob/trunk/file.c#L940
 static VALUE
 stat_ctime(const struct stat *st)
 {
-    struct timespec ts = stat_ctimespec(st);
-    return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
+    return stat_time(stat_ctimespec(st));
 }
 
 #define HAVE_STAT_BIRTHTIME
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]