浏览代码

LibWeb: Use StringView instead of String in SVG::AttributeParser

This saves copying the string data, since the AttributeParser is always
temporary.
Sam Atkins 3 年之前
父节点
当前提交
ab440b3e50
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 1 1
      Userland/Libraries/LibWeb/SVG/AttributeParser.cpp
  2. 2 2
      Userland/Libraries/LibWeb/SVG/AttributeParser.h

+ 1 - 1
Userland/Libraries/LibWeb/SVG/AttributeParser.cpp

@@ -11,7 +11,7 @@
 
 
 namespace Web::SVG {
 namespace Web::SVG {
 
 
-AttributeParser::AttributeParser(String source)
+AttributeParser::AttributeParser(StringView source)
     : m_source(move(source))
     : m_source(move(source))
 {
 {
 }
 }

+ 2 - 2
Userland/Libraries/LibWeb/SVG/AttributeParser.h

@@ -35,7 +35,7 @@ struct PathInstruction {
 
 
 class AttributeParser final {
 class AttributeParser final {
 public:
 public:
-    AttributeParser(String source);
+    AttributeParser(StringView source);
     ~AttributeParser() = default;
     ~AttributeParser() = default;
 
 
     Vector<PathInstruction> parse_path_data();
     Vector<PathInstruction> parse_path_data();
@@ -85,7 +85,7 @@ private:
     char ch() const { return m_source[m_cursor]; }
     char ch() const { return m_source[m_cursor]; }
     char consume() { return m_source[m_cursor++]; }
     char consume() { return m_source[m_cursor++]; }
 
 
-    String m_source;
+    StringView m_source;
     size_t m_cursor { 0 };
     size_t m_cursor { 0 };
     Vector<PathInstruction> m_instructions;
     Vector<PathInstruction> m_instructions;
 };
 };