Sha256: 69b6f475e3df81c51f9a43424e7197d98068b5342dc547b8466ec525f68df83c

Contents?: true

Size: 1.7 KB

Versions: 49

Compression:

Stored size: 1.7 KB

Contents

#include "sass.hpp"
#include "ast.hpp"
#include "subset_map.hpp"

namespace Sass {

  void Subset_Map::put(const Compound_Selector_Obj& sel, const SubSetMapPair& value)
  {
    if (sel->empty()) throw std::runtime_error("internal error: subset map keys may not be empty");
    size_t index = values_.size();
    values_.push_back(value);
    for (size_t i = 0, S = sel->length(); i < S; ++i)
    {
      hash_[(*sel)[i]].push_back(std::make_pair(sel, index));
    }
  }

  std::vector<SubSetMapPair> Subset_Map::get_kv(const Compound_Selector_Obj& sel)
  {
    SimpleSelectorDict dict(sel->begin(), sel->end()); // XXX Set
    std::vector<size_t> indices;
    for (size_t i = 0, S = sel->length(); i < S; ++i) {
      if (!hash_.count((*sel)[i])) {
        continue;
      }
      const std::vector<std::pair<Compound_Selector_Obj, size_t> >& subsets = hash_[(*sel)[i]];
      for (const std::pair<Compound_Selector_Obj, size_t>& item : subsets) {
        bool include = true;
        for (const Simple_Selector_Obj& it : item.first->elements()) {
          auto found = dict.find(it);
          if (found == dict.end()) {
            include = false;
            break;
          }
        }
        if (include) indices.push_back(item.second);
      }
    }
    sort(indices.begin(), indices.end());
    std::vector<size_t>::iterator indices_end = unique(indices.begin(), indices.end());
    indices.resize(distance(indices.begin(), indices_end));

    std::vector<SubSetMapPair> results;
    for (size_t i = 0, S = indices.size(); i < S; ++i) {
      results.push_back(values_[indices[i]]);
    }
    return results;
  }

  std::vector<SubSetMapPair> Subset_Map::get_v(const Compound_Selector_Obj& sel)
  {
    return get_kv(sel);
  }

}

Version data entries

49 entries across 47 versions & 16 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/node-sass/src/libsass/src/subset_map.cpp
optimacms-0.1.61 spec/dummy/node_modules/@rails/webpacker/node_modules/node-sass/src/libsass/src/subset_map.cpp
disco_app-0.18.0 test/dummy/node_modules/node-sass/src/libsass/src/subset_map.cpp
disco_app-0.18.2 test/dummy/node_modules/node-sass/src/libsass/src/subset_map.cpp
tang-0.2.1 spec/tang_app/node_modules/node-sass/src/libsass/src/subset_map.cpp
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/node-sass/src/libsass/src/subset_map.cpp
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/node-sass/src/libsass/src/subset_map.cpp
ruby2js-4.0.4 lib/tasks/testrails/node_modules/node-sass/src/libsass/src/subset_map.cpp
ruby2js-4.0.3 lib/tasks/testrails/node_modules/node-sass/src/libsass/src/subset_map.cpp
tang-0.2.0 spec/tang_app/node_modules/node-sass/src/libsass/src/subset_map.cpp
tang-0.1.0 spec/tang_app/node_modules/node-sass/src/libsass/src/subset_map.cpp
tang-0.0.9 spec/tang_app/node_modules/node-sass/src/libsass/src/subset_map.cpp
enju_library-0.3.8 spec/dummy/node_modules/node-sass/src/libsass/src/subset_map.cpp
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/sassc-2.0.0/ext/libsass/src/subset_map.cpp
ilog-0.4.1 node_modules/node-sass/src/libsass/src/subset_map.cpp
ilog-0.4.0 node_modules/node-sass/src/libsass/src/subset_map.cpp
ilog-0.3.3 node_modules/node-sass/src/libsass/src/subset_map.cpp
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sassc-2.0.1/ext/libsass/src/subset_map.cpp
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sassc-2.0.1/ext/libsass/src/subset_map.cpp
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sassc-2.0.1/ext/libsass/src/subset_map.cpp