Code

store: Don't update unchanged attribute values.
authorSebastian Harl <sh@tokkee.org>
Fri, 4 Jul 2014 18:57:41 +0000 (20:57 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 4 Jul 2014 18:57:41 +0000 (20:57 +0200)
When handling dynamically allocated data, this would generate unnecessary
memory churn.

src/core/store.c

index 7de75b1ee546e6a49509746fa0a13410834ba779..1c04a77cb6a6c1ce252380211ee8bdb9de188309 100644 (file)
@@ -327,6 +327,10 @@ store_attr(sdb_llist_t *attributes, const char *key, const sdb_data_t *value,
        if (status)
                return status;
 
+       /* don't update unchanged values */
+       if (! sdb_data_cmp(&ATTR(attr)->value, value))
+               return status;
+
        assert(attr);
        if (sdb_data_copy(&ATTR(attr)->value, value))
                return -1;