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>
GDateTime is an opaque data type containing a date and time
representation. It's immutable once created and reference
counted.
https://bugzilla.gnome.org/show_bug.cgi?id=50076
Based on the code by: Christian Hergert <chris@dronelabs.com>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
This is causing very serious problems when doing out-of-tree builds from
tarballs on architectures that are different from the architecture that
the tarball was created on.
This commit breaks the build in those cases, but I'll fix that in the
next commits.
https://bugzilla.gnome.org/show_bug.cgi?id=626107
As discussed with Ryan on IRC.
This check is crucial because it guarantees that
g_variant_get_string() will _always_ return valid UTF-8. Except in
cases where the programmer used unsafe API such as
g_variant_new_from_data() and setting @trusted to TRUE.
In fact, this check revealed a flaw in my polkit gdbus port
(lt-polkitd:11632): GLib-CRITICAL **: g_variant_new_string: assertion
`g_utf8_validate (string, len, NULL)' failed
and with this I could easily find the problem by using gdb(1) and
G_DBUS=fatal-warnings.
Without this check we'd pass the non-UTF8 string all the way to the
message bus and the bus would then disconnect us. So instead I was
seeing
g_dbus_connection_real_closed: Remote peer vanished with error:
Underlying GIOStream returned 0 bytes on an async read
(g-io-error-quark, 0). Exiting.
and then SIGTERM as raised by g_dbus_connection_real_closed() and my
polkitd process would exit. This behavior is much harder to debug than
failing early (as this patch implements).
Signed-off-by: David Zeuthen <davidz@redhat.com>