Ticket #58347: make_array.patch

File make_array.patch, 4.9 KB (added by mgieseki (Martin Gieseking), 6 years ago)
  • src/optimizer/AttributeExtractor.cpp

    # HG changeset patch
    # User Martin Gieseking <martin.gieseking@uos.de>
    # Date 1555578878 -7200
    #      Thu Apr 18 11:14:38 2019 +0200
    # Node ID 4fa1e45d2e2a5b50e385244813b3b8a34629a1f5
    # Parent  736ab658460f07a5019a7cf049465ac1e14a3a2c
    removed util::make_array() due to compatibility issues
    
    diff --git a/src/optimizer/AttributeExtractor.cpp b/src/optimizer/AttributeExtractor.cpp
    a b  
    113113 *  @return true if the element is groupable */
    114114bool AttributeExtractor::groupable (const XMLElement &elem) {
    115115        // https://www.w3.org/TR/SVG/struct.html#GElement
    116         static constexpr auto names = util::make_array(
     116        static const char *names[] = {
    117117                "a", "altGlyphDef", "animate", "animateColor", "animateMotion", "animateTransform",
    118118                "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "filter",
    119119                "font", "font-face", "foreignObject", "g", "image", "line", "linearGradient", "marker",
    120120                "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "set",
    121121                "style", "switch", "symbol", "text", "title", "use", "view"
    122         );
    123         return binary_search(names.begin(), names.end(), elem.name(), [](const string &name1, const string &name2) {
     122        };
     123        return binary_search(begin(names), end(names), elem.name(), [](const string &name1, const string &name2) {
    124124                return name1 < name2;
    125125        });
    126126}
     
    136136        // clip-path is not inheritable but can be moved to the parent element as long as
    137137        // no child gets an different clip-path attribute
    138138        // https://www.w3.org/TR/SVG11/styling.html#Inheritance
    139         static constexpr auto names = util::make_array(
     139        static const char *names[] = {
    140140                "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile",
    141141                "color-rendering", "direction", "fill", "fill-opacity", "fill-rule", "font", "font-family", "font-size",
    142142                "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "glyph-orientation-horizontal",
    143143                "glyph-orientation-vertical", "letter-spacing", "paint-order", "stroke", "stroke-dasharray", "stroke-dashoffset",
    144144                "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "transform",
    145145                "visibility", "word-spacing", "writing-mode"
    146         );
    147         return binary_search(names.begin(), names.end(), attrib.name, [](const string &name1, const string &name2) {
     146        };
     147        return binary_search(begin(names), end(names), attrib.name, [](const string &name1, const string &name2) {
    148148                return name1 < name2;
    149149        });
    150150}
     
    159159        // the 'fill' attribute of animation elements has different semantics than
    160160        // that of graphics elements => don't extract it from animation nodes
    161161        // https://www.w3.org/TR/SVG11/animate.html#TimingAttributes
    162         static constexpr auto names = util::make_array(
     162        static const char *names[] = {
    163163                "animate", "animateColor", "animateMotion", "animateTransform", "set"
    164         );
    165         auto it = find_if(names.begin(), names.end(), [&](const string &name) {
     164        };
     165        auto it = find_if(begin(names), end(names), [&](const string &name) {
    166166                return element.name() == name;
    167167        });
    168         return it == names.end();
     168        return it == end(names);
    169169}
    170170
    171171
  • src/optimizer/GroupCollapser.cpp

    diff --git a/src/optimizer/GroupCollapser.cpp b/src/optimizer/GroupCollapser.cpp
    a b  
    132132bool GroupCollapser::collapsible (const XMLElement &element) {
    133133        // the 'fill' attribute of animation elements has different semantics than
    134134        // that of graphics elements => don't collapse them
    135         static constexpr auto names = util::make_array(
     135        static const char *names[] = {
    136136                "animate", "animateColor", "animateMotion", "animateTransform", "set"
    137         );
    138         auto it = find_if(names.begin(), names.end(), [&](const string &name) {
     137        };
     138        auto it = find_if(begin(names), end(names), [&](const string &name) {
    139139                return element.name() == name;
    140140        });
    141         return it == names.end();
     141        return it == end(names);
    142142}
    143143
    144144
     
    155155                }
    156156        }
    157157        // these attributes prevent a group from being unwrapped
    158         static constexpr auto attribs = util::make_array(
     158        static const char *attribs[] = {
    159159                "class", "id", "filter", "mask", "style"
    160         );
    161         auto it = find_if(attribs.begin(), attribs.end(), [&](const string &name) {
     160        };
     161        auto it = find_if(begin(attribs), end(attribs), [&](const string &name) {
    162162                return source.hasAttribute(name) || dest.hasAttribute(name);
    163163        });
    164         return it == attribs.end();
     164        return it == end(attribs);
    165165}
  • src/utility.hpp

    diff --git a/src/utility.hpp b/src/utility.hpp
    a b  
    103103    return std::unique_ptr<T>{static_cast<T*>(old.release())};
    104104}
    105105
    106 
    107 template <typename... T>
    108 constexpr auto make_array (T&&... values) ->
    109         std::array<typename std::decay<typename std::common_type<T...>::type>::type, sizeof...(T)> {
    110                 return std::array<typename std::decay<typename std::common_type<T...>::type>::type, sizeof...(T)>{
    111                         std::forward<T>(values)...
    112                 };
    113         }
    114 
    115106} // namespace util
    116107
    117108#endif