more elegant way of restoring the SYNC flag
@@ -1255,22 +1255,15 @@ static elektraCursor backendsDivideInternal (KeySet * backends, elektraCursor *
Key * k = ksAtCursor (ks, cur);
Key * nextBackendKey = *curBackend >= ksGetSize (backends) - 1 ? defaultBackendKey : ksAtCursor (backends, *curBackend + 1);
- bool originalKeyNeedsSync = keyNeedSync (k) == 1;
-
if (keyIsBelowOrSame (defaultBackendKey, k) == 1)
{
- Key * newKey = keyDup (k, KEY_CP_ALL);
+ Key * d = keyDup (k, KEY_CP_ALL);
- if (originalKeyNeedsSync)
- {
- set_bit (newKey->flags, KEY_FLAG_SYNC);
- }
- else
- {
- clear_bit (newKey->flags, KEY_FLAG_SYNC);
- }
+ // set the value of the sync flag to the same value as the original key
+ clear_bit (d->flags, KEY_FLAG_SYNC);
+ d->flags |= k->flags & KEY_FLAG_SYNC;
- ksAppendKey (defaultBackendData->keys, newKey);
+ ksAppendKey (defaultBackendData->keys, d);
}
// nextBackendKey == NULL happens during bootstrap
else if (nextBackendKey != NULL && keyCmp (k, nextBackendKey) >= 0)
@@ -1281,20 +1274,15 @@ static elektraCursor backendsDivideInternal (KeySet * backends, elektraCursor *
}
else if (*curBackend < 0 || keyIsBelowOrSame (backendKey, k) == 1)
{
- backendData->keyNeedsSync = backendData->keyNeedsSync || originalKeyNeedsSync;
+ backendData->keyNeedsSync = backendData->keyNeedsSync || keyNeedSync (k) == 1;
- Key * newKey = keyDup (k, KEY_CP_ALL);
+ Key * d = keyDup (k, KEY_CP_ALL);
- if (originalKeyNeedsSync)
- {
- set_bit (newKey->flags, KEY_FLAG_SYNC);
- }
- else
- {
- clear_bit (newKey->flags, KEY_FLAG_SYNC);
- }
+ // set the value of the sync flag to the same value as the original key
+ clear_bit (d->flags, KEY_FLAG_SYNC);
+ d->flags |= k->flags & KEY_FLAG_SYNC;
- ksAppendKey (backendData->keys, newKey);
+ ksAppendKey (backendData->keys, d);
}
else
{
