From 3d3e4d52b46d98cca524509a386a69e5dee1ed2a Mon Sep 17 00:00:00 2001 From: iska Date: Sat, 2 May 2015 20:52:03 +0200 Subject: [PATCH] Add a NO_DOM_CHECKS macro to disable validations for DOM manipulations DOM validation checks are expensive. This macro would allow for removing these checks from the compiled product, which would increase performance by about 20-30%. However, the user is responsible for the validity of the manipulations and the resulting DOM. --- HTMLKit/HTMLNode.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/HTMLKit/HTMLNode.m b/HTMLKit/HTMLNode.m index d4c51aa..6aac8c2 100644 --- a/HTMLKit/HTMLNode.m +++ b/HTMLKit/HTMLNode.m @@ -153,7 +153,9 @@ - (HTMLNode *)insertNode:(HTMLNode *)node beforeChildNode:(HTMLNode *)child { +#ifndef HTMLKIT_NO_DOM_CHECKS [self ensurePreInsertionValidityOfNode:node beforeChildNode:child]; +#endif [self.ownerDocument adoptNode:node]; @@ -178,7 +180,9 @@ - (HTMLNode *)replaceChildNode:(HTMLNode *)child withNode:(HTMLNode *)node { +#ifndef HTMLKIT_NO_DOM_CHECKS [self ensureReplacementValidityOfChildNode:child withNode:node]; +#endif [self insertNode:node beforeChildNode:child]; [child removeFromParentNode]; @@ -269,6 +273,7 @@ } } +#ifndef HTMLKIT_NO_DOM_CHECKS #pragma mark - Validity Checks @@ -431,6 +436,8 @@ NS_INLINE void CheckInvalidCombination(HTMLNode *parent, HTMLNode *node, NSStrin } } +#endif + #pragma mark - NSCopying - (id)copyWithZone:(NSZone *)zone