From f3612abf5ab55d3277073635a29ce2c919081acd Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Tue, 27 Oct 2009 16:48:39 -0500 Subject: [PATCH 01/20] ole32: Reduce duplicated code in adjustPropertyChain. Most of the work is the same regardless of relation type, so bring those parts out of the relation type test. --- dlls/ole32/storage32.c | 106 +++++++++-------------------------------------- 1 files changed, 21 insertions(+), 85 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index fe74fb9..470dc83 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -2135,107 +2135,43 @@ static HRESULT adjustPropertyChain( HRESULT hr = S_OK; BOOL res = TRUE; - if (typeOfRelation == PROPERTY_RELATION_PREVIOUS) + if (propertyToDelete.leftChild != PROPERTY_NULL) { - if (propertyToDelete.leftChild != PROPERTY_NULL) - { - /* - * Set the parent previous to the property to delete previous - */ - newLinkProperty = propertyToDelete.leftChild; + /* + * Replace the deleted entry with its left child + */ + newLinkProperty = propertyToDelete.leftChild; - if (propertyToDelete.rightChild != PROPERTY_NULL) - { - /* - * We also need to find a storage for the other link, setup variables - * to do this at the end... - */ - needToFindAPlaceholder = TRUE; - storeNode = propertyToDelete.leftChild; - toStoreNode = propertyToDelete.rightChild; - relationType = PROPERTY_RELATION_NEXT; - } - } - else if (propertyToDelete.rightChild != PROPERTY_NULL) + if (propertyToDelete.rightChild != PROPERTY_NULL) { /* - * Set the parent previous to the property to delete next + * We also need to find a place for the other link, setup variables + * to do this at the end... */ - newLinkProperty = propertyToDelete.rightChild; + needToFindAPlaceholder = TRUE; + storeNode = propertyToDelete.leftChild; + toStoreNode = propertyToDelete.rightChild; + relationType = PROPERTY_RELATION_NEXT; } - + } + else if (propertyToDelete.rightChild != PROPERTY_NULL) + { /* - * Link it for real... + * Replace the deleted entry with its right child */ - parentProperty.leftChild = newLinkProperty; + newLinkProperty = propertyToDelete.rightChild; + } + if (typeOfRelation == PROPERTY_RELATION_PREVIOUS) + { + parentProperty.leftChild = newLinkProperty; } else if (typeOfRelation == PROPERTY_RELATION_NEXT) { - if (propertyToDelete.leftChild != PROPERTY_NULL) - { - /* - * Set the parent next to the property to delete next previous - */ - newLinkProperty = propertyToDelete.leftChild; - - if (propertyToDelete.rightChild != PROPERTY_NULL) - { - /* - * We also need to find a storage for the other link, setup variables - * to do this at the end... - */ - needToFindAPlaceholder = TRUE; - storeNode = propertyToDelete.leftChild; - toStoreNode = propertyToDelete.rightChild; - relationType = PROPERTY_RELATION_NEXT; - } - } - else if (propertyToDelete.rightChild != PROPERTY_NULL) - { - /* - * Set the parent next to the property to delete next - */ - newLinkProperty = propertyToDelete.rightChild; - } - - /* - * Link it for real... - */ parentProperty.rightChild = newLinkProperty; } else /* (typeOfRelation == PROPERTY_RELATION_DIR) */ { - if (propertyToDelete.leftChild != PROPERTY_NULL) - { - /* - * Set the parent dir to the property to delete previous - */ - newLinkProperty = propertyToDelete.leftChild; - - if (propertyToDelete.rightChild != PROPERTY_NULL) - { - /* - * We also need to find a storage for the other link, setup variables - * to do this at the end... - */ - needToFindAPlaceholder = TRUE; - storeNode = propertyToDelete.leftChild; - toStoreNode = propertyToDelete.rightChild; - relationType = PROPERTY_RELATION_NEXT; - } - } - else if (propertyToDelete.rightChild != PROPERTY_NULL) - { - /* - * Set the parent dir to the property to delete next - */ - newLinkProperty = propertyToDelete.rightChild; - } - - /* - * Link it for real... - */ parentProperty.dirProperty = newLinkProperty; } -- 1.6.3.3