datetime: Avoid excessive copies in add_full()
authorEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 25 Aug 2010 22:00:31 +0000 (23:00 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 25 Aug 2010 22:04:42 +0000 (23:04 +0100)
commit026375b395fcdc2336666546afd2f21e7ee8bc67
treede885375f822f5157963897e7bdd8b8a7b9df8f8
parent0d0a9bb4485069a56caf139346e6a6aad81c4efd
datetime: Avoid excessive copies in add_full()

The current implementation of g_date_time_add_full() creates multiple
GDateTime temporary objects and unrefs them immediately; even with the
slice allocator this could result in a performance bottleneck,
especially if the atomic integer operations fall back to slow paths.

We can isolate the components of the add_full() operation and create
internal modifiers that operate on an existing GDateTime; this brings
down the number of GDateTime copies created from six to one.

While at it, the test suite for add_full() should have more checks for
roll-over of months and days.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
glib/gdatetime.c
glib/tests/gdatetime.c