@@ -171,15 +171,15 @@ cdef class LexborNode:
171171
172172 if not deep:
173173 container = TextContainer(separator, strip)
174- if self . _is_node_type(LXB_DOM_NODE_TYPE_TEXT):
174+ if _is_node_type(self .node, LXB_DOM_NODE_TYPE_TEXT):
175175 text = < unsigned char * > lexbor_str_data_noi(& (< lxb_dom_character_data_t * > self .node).data)
176176 if text != NULL :
177177 if not skip_empty or not self .is_empty_text_node:
178178 py_text = text.decode(_ENCODING)
179179 container.append(py_text)
180180
181181 while node != NULL :
182- if node.type == LXB_DOM_NODE_TYPE_TEXT:
182+ if _is_node_type( node, LXB_DOM_NODE_TYPE_TEXT) :
183183 text = < unsigned char * > lexbor_str_data_noi(& (< lxb_dom_character_data_t * > node).data)
184184 if text != NULL :
185185 if not skip_empty or not is_empty_text_node(node):
@@ -189,7 +189,7 @@ cdef class LexborNode:
189189 return container.text
190190 else :
191191 container = TextContainer(separator, strip)
192- if self . _is_node_type(LXB_DOM_NODE_TYPE_TEXT):
192+ if _is_node_type(self .node, LXB_DOM_NODE_TYPE_TEXT):
193193 text = < unsigned char * > lexbor_str_data_noi(& (< lxb_dom_character_data_t * > self .node).data)
194194 if text != NULL :
195195 if not skip_empty or not self .is_empty_text_node:
@@ -372,7 +372,7 @@ cdef class LexborNode:
372372 cdef size_t str_len = 0
373373 attributes = dict ()
374374
375- if not self . _is_node_type(LXB_DOM_NODE_TYPE_ELEMENT):
375+ if not _is_node_type(self .node, LXB_DOM_NODE_TYPE_ELEMENT):
376376 return attributes
377377
378378 while attr != NULL :
@@ -953,7 +953,7 @@ cdef class LexborNode:
953953 cdef unsigned char * text
954954 cdef lxb_dom_node_t * node = < lxb_dom_node_t * > self .node.first_child
955955 cdef TextContainer container
956- if not self . _is_node_type(LXB_DOM_NODE_TYPE_TEXT):
956+ if not _is_node_type(self .node, LXB_DOM_NODE_TYPE_TEXT):
957957 return None
958958
959959 text = < unsigned char * > lexbor_str_data_noi(& (< lxb_dom_character_data_t * > self .node).data)
@@ -1044,28 +1044,25 @@ cdef class LexborNode:
10441044 node = lxb_dom_node_clone(< lxb_dom_node_t * > self .node, 1 )
10451045 return LexborNode.new(node , self.parser )
10461046
1047- cdef inline bint _is_node_type(self , lxb_dom_node_type_t expected_type ):
1048- return self .node != NULL and self .node.type == expected_type
1049-
10501047 @property
10511048 def is_element_node(self ) -> bool:
10521049 """Return True if the node represents an element node."""
1053- return self. _is_node_type(LXB_DOM_NODE_TYPE_ELEMENT )
1050+ return _is_node_type(self. node , LXB_DOM_NODE_TYPE_ELEMENT )
10541051
10551052 @property
10561053 def is_text_node(self ) -> bool:
10571054 """Return True if the node represents a text node."""
1058- return self. _is_node_type(LXB_DOM_NODE_TYPE_TEXT )
1055+ return _is_node_type(self. node , LXB_DOM_NODE_TYPE_TEXT )
10591056
10601057 @property
10611058 def is_comment_node(self ) -> bool:
10621059 """Return True if the node represents a comment node."""
1063- return self. _is_node_type(LXB_DOM_NODE_TYPE_COMMENT )
1060+ return _is_node_type(self. node , LXB_DOM_NODE_TYPE_COMMENT )
10641061
10651062 @property
10661063 def is_document_node(self ) -> bool:
10671064 """Return True if the node represents a document node."""
1068- return self. _is_node_type(LXB_DOM_NODE_TYPE_DOCUMENT )
1065+ return _is_node_type(self. node , LXB_DOM_NODE_TYPE_DOCUMENT )
10691066
10701067 @property
10711068 def is_empty_text_node(self ) -> bool:
@@ -1144,3 +1141,6 @@ cdef lxb_status_t serialize_fragment(lxb_dom_node_t *node, lexbor_str_t *lxb_str
11441141 node = node.next
11451142
11461143 return LXB_STATUS_OK
1144+
1145+ cdef inline bint _is_node_type(lxb_dom_node_t * node, lxb_dom_node_type_t expected_type):
1146+ return node != NULL and node.type == expected_type
0 commit comments