Module: wine Branch: master Commit: a7e69339dcda3d3360f3b03bac5272f9c1c0176d URL: http://source.winehq.org/git/wine.git/?a=commit;h=a7e69339dcda3d3360f3b03bac...
Author: Vincent Povirk vincent@codeweavers.com Date: Tue Oct 27 16:48:39 2009 -0500
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; }