Changeset 140453 in webkit
- Timestamp:
- Jan 22, 2013 1:01:42 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r140452 r140453 1 2013-01-22 Eric Seidel <eric@webkit.org> 2 3 Make CompactHTMLToken a little more compact 4 https://bugs.webkit.org/show_bug.cgi?id=107317 5 6 Reviewed by Darin Adler. 7 8 Reduce the size of CompactHTMLToken by two pointers. 9 The abuse of the attribute vector to store the DOCTYPE strings 10 is kinda lame, but makes a lot of sense given how rare DOCTYPE tokens are. 11 12 The resulting CompactHTMLToken vector should be a smaller malloc and thus faster. 13 However I saw no perf change on html-parser-srcdoc.html. 14 15 * html/parser/CompactHTMLToken.cpp: 16 (SameSizeAsCompactHTMLToken): 17 (WebCore): 18 (WebCore::CompactHTMLToken::CompactHTMLToken): 19 (WebCore::CompactHTMLToken::isSafeToSendToAnotherThread): 20 * html/parser/CompactHTMLToken.h: 21 (WebCore::CompactHTMLToken::type): 22 (CompactHTMLToken): 23 (WebCore::CompactHTMLToken::publicIdentifier): 24 (WebCore::CompactHTMLToken::systemIdentifier): 25 1 26 2013-01-22 Elliott Sprehn <esprehn@chromium.org> 2 27 -
trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp
r139945 r140453 34 34 namespace WebCore { 35 35 36 struct SameSizeAsCompactHTMLToken { 37 unsigned bitfields; 38 String name; 39 Vector<CompactAttribute> vector; 40 }; 41 42 COMPILE_ASSERT(sizeof(CompactHTMLToken) == sizeof(SameSizeAsCompactHTMLToken), CompactHTMLToken_should_stay_small); 43 36 44 CompactHTMLToken::CompactHTMLToken(const HTMLToken& token) 37 45 : m_type(token.type()) … … 41 49 ASSERT_NOT_REACHED(); 42 50 break; 43 case HTMLTokenTypes::DOCTYPE: 51 case HTMLTokenTypes::DOCTYPE: { 44 52 m_data = String(token.name().data(), token.name().size()); 45 m_publicIdentifier = String(token.publicIdentifier().data(), token.publicIdentifier().size()); 46 m_systemIdentifier = String(token.systemIdentifier().data(), token.systemIdentifier().size()); 53 // There is only 1 DOCTYPE token per document, so to avoid increasing the 54 // size of CompactHTMLToken, we just use the m_attributes vector. 55 String publicIdentifier(token.publicIdentifier().data(), token.publicIdentifier().size()); 56 String systemIdentifier(token.systemIdentifier().data(), token.systemIdentifier().size()); 57 m_attributes.append(CompactAttribute(publicIdentifier, systemIdentifier)); 47 58 break; 59 } 48 60 case HTMLTokenTypes::EndOfFile: 49 61 break; … … 89 101 return false; 90 102 } 91 92 return isStringSafeToSendToAnotherThread(m_data) 93 && isStringSafeToSendToAnotherThread(m_publicIdentifier) 94 && isStringSafeToSendToAnotherThread(m_systemIdentifier); 103 return isStringSafeToSendToAnotherThread(m_data); 95 104 } 96 105 -
trunk/Source/WebCore/html/parser/CompactHTMLToken.h
r139945 r140453 61 61 bool isSafeToSendToAnotherThread() const; 62 62 63 HTMLTokenTypes::Type type() const { return m_type; }63 HTMLTokenTypes::Type type() const { return static_cast<HTMLTokenTypes::Type>(m_type); } 64 64 const String& data() const { return m_data; } 65 65 bool selfClosing() const { return m_selfClosing; } 66 66 const Vector<CompactAttribute>& attributes() const { return m_attributes; } 67 67 68 const String& publicIdentifier() const { return m_publicIdentifier; } 69 const String& systemIdentifier() const { return m_systemIdentifier; } 68 // There is only 1 DOCTYPE token per document, so to avoid increasing the 69 // size of CompactHTMLToken, we just use the m_attributes vector. 70 const String& publicIdentifier() const { return m_attributes[0].name(); } 71 const String& systemIdentifier() const { return m_attributes[0].value(); } 70 72 71 73 private: 72 HTMLTokenTypes::Type m_type; 74 unsigned m_type : 4; 75 bool m_selfClosing : 1; 76 73 77 String m_data; // "name", "characters", or "data" depending on m_type 74 bool m_selfClosing;75 78 Vector<CompactAttribute> m_attributes; 76 77 // For doctype only.78 String m_publicIdentifier;79 String m_systemIdentifier;80 79 }; 81 80
Note: See TracChangeset
for help on using the changeset viewer.