mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:42:43 +00:00 
			
		
		
		
	LibWeb: Add cached global attribute name FlyStrings
Instead of creating extremely common FlyStrings like "id" and "class"
on demand every time they are needed, we now have AttributeNames.h,
which provides Web::HTML::AttributeNames::{id,class_}
This avoids a bunch of string allocations during selector matching.
			
			
This commit is contained in:
		
							parent
							
								
									5069d380a8
								
							
						
					
					
						commit
						82444048de
					
				
					 7 changed files with 102 additions and 5 deletions
				
			
		|  | @ -27,6 +27,7 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <AK/Forward.h> | ||||
| #include <LibWeb/DOM/AttributeNames.h> | ||||
| #include <LibWeb/Forward.h> | ||||
| #include <LibWeb/TreeNode.h> | ||||
| 
 | ||||
|  | @ -39,7 +40,7 @@ public: | |||
|     { | ||||
|         const Element* found_element = nullptr; | ||||
|         static_cast<const NodeType*>(this)->template for_each_in_subtree_of_type<Element>([&](auto& element) { | ||||
|             if (element.attribute("id") == id) { | ||||
|             if (element.attribute(HTML::AttributeNames::id) == id) { | ||||
|                 found_element = &element; | ||||
|                 return IterationDecision::Break; | ||||
|             } | ||||
|  | @ -53,7 +54,7 @@ public: | |||
|     } | ||||
| 
 | ||||
| protected: | ||||
|     NonElementParentNode() {} | ||||
|     NonElementParentNode() { } | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling