Re: [PATCH v3 3/4] rtc: lib: Implement rtc_time64_to_tm() in terms of time64_to_tm()
From: Thomas Weißschuh
Date: Tue Dec 01 2026 - 11:08:44 EST
On Tue, Dec 01, 2026 at 04:04:47PM +0100, Alexandre Belloni wrote:
> On 01/12/2026 10:05:36+0100, Thomas Weißschuh (Schneider Electric) wrote:
> > On Mon, Nov 30, 2026 at 09:22:32PM +0100, Alexandre Belloni wrote:
> > > On 30/11/2026 15:20:49+0100, Thomas Weißschuh (Schneider Electric) wrote:
> > > > The core timekeeping code already provides a function to convert seconds
> > > > since the epoch to a 'struct tm'. This can be reused for a the
> > > > 'struct rtc_time' conversion.
> > > >
> > > > time64_to_tm() can handle a larger range of dates. It is also
> > > > 20% slower, but this function is not a hot-path anyways.
> > > > On the other hand this saves ~600 bytes of .text.
> > > >
> > >
> > > While not in the hot path, this is actually time sensitive which is why
> > > I always hesitated doing this change.
> >
> > time64_to_tm() has been optimized by Cassio recently.
> > So the absolute performance should be much better than the original
> > rtc_time64_to_tm().
> >
>
> Well, rtc_time64_to_tm was also optimized so I don't get your point here.
My reasoning was that apparently the old version of rtc_time64_to_tm() was
already good enough. The optimization from Cassio looks to be a drive-by commit
because he could and was not driven by a specific real-world need to make the
function faster. So if that original version was good enough then the new
one should be, too. Faster would be better, but I didn't expect anyone to care,
so I didn't spend the effort.
Thomas