@@ -277,8 +277,24 @@ namespace Sass {
277
277
// extra <std::vector> internally to maintain insertion order for interation.
278
278
// ///////////////////////////////////////////////////////////////////////////
279
279
class Hashed {
280
+ struct HashExpression {
281
+ size_t operator () (Expression* ex) const {
282
+ return ex ? ex->hash () : 0 ;
283
+ }
284
+ };
285
+ struct CompareExpression {
286
+ bool operator ()(const Expression* lhs, const Expression* rhs) const {
287
+ return lhs && rhs && *lhs == *rhs;
288
+ }
289
+ };
290
+ typedef std::unordered_map<
291
+ Expression*, // key
292
+ Expression*, // value
293
+ HashExpression, // hasher
294
+ CompareExpression // compare
295
+ > ExpressionMap;
280
296
private:
281
- std::unordered_map<Expression*, Expression*> elements_;
297
+ ExpressionMap elements_;
282
298
std::vector<Expression*> list_;
283
299
protected:
284
300
size_t hash_;
@@ -287,7 +303,7 @@ namespace Sass {
287
303
void reset_duplicate_key () { duplicate_key_ = 0 ; }
288
304
virtual void adjust_after_pushing (std::pair<Expression*, Expression*> p) { }
289
305
public:
290
- Hashed (size_t s = 0 ) : elements_(std::unordered_map<Expression*, Expression*> (s)), list_(std::vector<Expression*>())
306
+ Hashed (size_t s = 0 ) : elements_(ExpressionMap (s)), list_(std::vector<Expression*>())
291
307
{ elements_.reserve (s); list_.reserve (s); reset_duplicate_key (); }
292
308
virtual ~Hashed ();
293
309
size_t length () const { return list_.size (); }
@@ -296,7 +312,7 @@ namespace Sass {
296
312
Expression* at (Expression* k) const ;
297
313
bool has_duplicate_key () const { return duplicate_key_ != 0 ; }
298
314
Expression* get_duplicate_key () const { return duplicate_key_; }
299
- const std::unordered_map<Expression*, Expression*> elements () { return elements_; }
315
+ const ExpressionMap elements () { return elements_; }
300
316
Hashed& operator <<(std::pair<Expression*, Expression*> p)
301
317
{
302
318
reset_hash ();
@@ -324,7 +340,7 @@ namespace Sass {
324
340
reset_duplicate_key ();
325
341
return *this ;
326
342
}
327
- const std::unordered_map<Expression*, Expression*> & pairs () const { return elements_; }
343
+ const ExpressionMap & pairs () const { return elements_; }
328
344
const std::vector<Expression*>& keys () const { return list_; }
329
345
330
346
std::unordered_map<Expression*, Expression*>::iterator end () { return elements_.end (); }
0 commit comments