Ignore:
Timestamp:
Mar 1, 2020, 4:40:05 PM (5 years ago)
Author:
Darin Adler
Message:

Move some vectors around instead of heap-allocating them and moving the pointers
https://bugs.webkit.org/show_bug.cgi?id=208422

Reviewed by Sam Weinig.

  • css/CSSKeyframeRule.cpp:

(WebCore::StyleRuleKeyframe::StyleRuleKeyframe): Take Vector&& instead of
unique_ptr<Vector>.
(WebCore::StyleRuleKeyframe::create): Moved these here from the header.
Take Vector&& instead of unique_ptr<Vector>.
(WebCore::StyleRuleKeyframe::setKeyText): Update since the result is a
Vector rather than a unique_ptr<Vector>.

  • css/CSSKeyframeRule.h: Updated for the above.
  • css/CSSKeyframesRule.cpp:

(WebCore::StyleRuleKeyframes::findKeyframeIndex const): Return Optional<size_t>
so we don't depend on notFound. This is our better modern pattern, since
notFound can work wrong if we mix size_t and unsigned, for example. Also
updatd since result of parseKeyFrameKeyList is now a Vector rather than
a unique_ptr<Vector>.
(WebCore::CSSKeyframesRule::deleteRule): Updated for the above.
(WebCore::CSSKeyframesRule::findRule): Ditto.

  • css/CSSKeyframesRule.h: Updated for the above.
  • css/parser/CSSParser.cpp:

(WebCore::CSSParser::parseKeyframeKeyList): Return Vector instead of
unique_ptr<Vector>.

  • css/parser/CSSParser.h: Updated for the above.
  • css/parser/CSSParserImpl.cpp:

(WebCore::CSSParserImpl::parseKeyframeKeyList): Return Vector instead of
unique_ptr<Vector>.
(WebCore::CSSParserImpl::consumeKeyframeStyleRule): Updated for the
above change.
(WebCore::CSSParserImpl::consumeKeyframeKeyList): Return Vector instead
of unique_ptr<Vector>.

  • css/parser/CSSParserImpl.h: Updated for the above.
  • platform/graphics/FloatPolygon.cpp:

(WebCore::FloatPolygon::FloatPolygon): Take Vector&& instead of
unique_ptr<Vector>.

  • platform/graphics/FloatPolygon.h: Take Vector&& instead of unique_ptr<Vector>.

Also changed m_vertices to a Vector instead of a unique_ptr<Vector>.

  • rendering/shapes/PolygonShape.h: Take Vector&& instead of unique_ptr<Vector>.
  • rendering/shapes/Shape.cpp:

(WebCore::createPolygonShape): Take Vector&& instead of unique_ptr<Vector>.
(WebCore::Shape::createShape): Use a Vector instead of a unique_ptr<Vector>.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSKeyframeRule.cpp

    r254514 r257696  
    4141}
    4242
    43 StyleRuleKeyframe::StyleRuleKeyframe(std::unique_ptr<Vector<double>> keys, Ref<StyleProperties>&& properties)
     43StyleRuleKeyframe::StyleRuleKeyframe(Vector<double>&& keys, Ref<StyleProperties>&& properties)
    4444    : StyleRuleBase(StyleRuleType::Keyframe)
    4545    , m_properties(WTFMove(properties))
    46     , m_keys(*keys)
     46    , m_keys(WTFMove(keys))
    4747{
    4848}
    49    
     49
     50Ref<StyleRuleKeyframe> StyleRuleKeyframe::create(Ref<StyleProperties>&& properties)
     51{
     52    return adoptRef(*new StyleRuleKeyframe(WTFMove(properties)));
     53}
     54
     55Ref<StyleRuleKeyframe> StyleRuleKeyframe::create(Vector<double>&& keys, Ref<StyleProperties>&& properties)
     56{
     57    return adoptRef(*new StyleRuleKeyframe(WTFMove(keys), WTFMove(properties)));
     58}
     59
    5060StyleRuleKeyframe::~StyleRuleKeyframe() = default;
    5161
     
    7282    ASSERT(!keyText.isNull());
    7383    auto keys = CSSParser::parseKeyframeKeyList(keyText);
    74     if (!keys || keys->isEmpty())
     84    if (keys.isEmpty())
    7585        return false;
    76     m_keys = *keys;
     86    m_keys = WTFMove(keys);
    7787    return true;
    7888}
Note: See TracChangeset for help on using the changeset viewer.