Skip to content

Commit efc1d5e

Browse files
committed
Merge pull request #1347 from mgreter/feature/code-cleanup
Some more code cleanups I have missed
2 parents 490c4ce + 6f44683 commit efc1d5e

File tree

5 files changed

+18
-23
lines changed

5 files changed

+18
-23
lines changed

eval.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,12 @@ namespace Sass {
497497

498498
// see if it's a relational expression
499499
switch(op_type) {
500-
case Sass_OP::EQ: return new (ctx.mem) Boolean(b->pstate(), eq(lhs, rhs, ctx));
501-
case Sass_OP::NEQ: return new (ctx.mem) Boolean(b->pstate(), !eq(lhs, rhs, ctx));
502-
case Sass_OP::GT: return new (ctx.mem) Boolean(b->pstate(), !lt(lhs, rhs, ctx) && !eq(lhs, rhs, ctx));
503-
case Sass_OP::GTE: return new (ctx.mem) Boolean(b->pstate(), !lt(lhs, rhs, ctx));
504-
case Sass_OP::LT: return new (ctx.mem) Boolean(b->pstate(), lt(lhs, rhs, ctx));
505-
case Sass_OP::LTE: return new (ctx.mem) Boolean(b->pstate(), lt(lhs, rhs, ctx) || eq(lhs, rhs, ctx));
500+
case Sass_OP::EQ: return new (ctx.mem) Boolean(b->pstate(), eq(lhs, rhs));
501+
case Sass_OP::NEQ: return new (ctx.mem) Boolean(b->pstate(), !eq(lhs, rhs));
502+
case Sass_OP::GT: return new (ctx.mem) Boolean(b->pstate(), !lt(lhs, rhs) && !eq(lhs, rhs));
503+
case Sass_OP::GTE: return new (ctx.mem) Boolean(b->pstate(), !lt(lhs, rhs));
504+
case Sass_OP::LT: return new (ctx.mem) Boolean(b->pstate(), lt(lhs, rhs));
505+
case Sass_OP::LTE: return new (ctx.mem) Boolean(b->pstate(), lt(lhs, rhs) || eq(lhs, rhs));
506506

507507
default: break;
508508
}
@@ -1065,7 +1065,7 @@ namespace Sass {
10651065

10661066
// All the binary helpers.
10671067

1068-
bool Eval::eq(Expression* lhs, Expression* rhs, Context& ctx)
1068+
bool Eval::eq(Expression* lhs, Expression* rhs)
10691069
{
10701070
Expression::Concrete_Type ltype = lhs->concrete_type();
10711071
Expression::Concrete_Type rtype = rhs->concrete_type();
@@ -1107,7 +1107,7 @@ namespace Sass {
11071107
if (l->length() != r->length()) return false;
11081108
if (l->separator() != r->separator()) return false;
11091109
for (size_t i = 0, L = l->length(); i < L; ++i) {
1110-
if (!eq((*l)[i], (*r)[i], ctx)) return false;
1110+
if (!eq((*l)[i], (*r)[i])) return false;
11111111
}
11121112
return true;
11131113
} break;
@@ -1117,7 +1117,7 @@ namespace Sass {
11171117
Map* r = static_cast<Map*>(rhs);
11181118
if (l->length() != r->length()) return false;
11191119
for (auto key : l->keys())
1120-
if (!eq(l->at(key), r->at(key), ctx)) return false;
1120+
if (!eq(l->at(key), r->at(key))) return false;
11211121
return true;
11221122
} break;
11231123
case Expression::NULL_VAL: {
@@ -1129,7 +1129,7 @@ namespace Sass {
11291129
return false;
11301130
}
11311131

1132-
bool Eval::lt(Expression* lhs, Expression* rhs, Context& ctx)
1132+
bool Eval::lt(Expression* lhs, Expression* rhs)
11331133
{
11341134
if (lhs->concrete_type() != Expression::NUMBER ||
11351135
rhs->concrete_type() != Expression::NUMBER)

eval.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ namespace Sass {
8686
Expression* fallback(U x) { return fallback_impl(x); }
8787

8888
// -- only need to define two comparisons, and the rest can be implemented in terms of them
89-
static bool eq(Expression*, Expression*, Context&);
90-
static bool lt(Expression*, Expression*, Context&);
89+
static bool eq(Expression*, Expression*);
90+
static bool lt(Expression*, Expression*);
9191
// -- arithmetic on the combinations that matter
9292
static Expression* op_numbers(Context&, enum Sass_OP, Number*, Number*);
9393
static Expression* op_number_color(Context&, enum Sass_OP, Number*, Color*);

functions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ namespace Sass {
10771077
Number* xi = dynamic_cast<Number*>(arglist->value_at_index(i));
10781078
if (!xi) error("`" + string(sig) + "` only takes numeric arguments", pstate);
10791079
if (least) {
1080-
if (Eval::lt(xi, least, ctx)) least = xi;
1080+
if (Eval::lt(xi, least)) least = xi;
10811081
} else least = xi;
10821082
}
10831083
return least;
@@ -1092,7 +1092,7 @@ namespace Sass {
10921092
Number* xi = dynamic_cast<Number*>(arglist->value_at_index(i));
10931093
if (!xi) error("`" + string(sig) + "` only takes numeric arguments", pstate);
10941094
if (greatest) {
1095-
if (Eval::lt(greatest, xi, ctx)) greatest = xi;
1095+
if (Eval::lt(greatest, xi)) greatest = xi;
10961096
} else greatest = xi;
10971097
}
10981098
return greatest;
@@ -1202,7 +1202,7 @@ namespace Sass {
12021202
*l << ARG("$list", Expression);
12031203
}
12041204
for (size_t i = 0, L = l->length(); i < L; ++i) {
1205-
if (Eval::eq(l->value_at_index(i), v, ctx)) return new (ctx.mem) Number(pstate, i+1);
1205+
if (Eval::eq(l->value_at_index(i), v)) return new (ctx.mem) Number(pstate, i+1);
12061206
}
12071207
return new (ctx.mem) Null(pstate);
12081208
}
@@ -1377,7 +1377,7 @@ namespace Sass {
13771377
for (auto key : m->keys()) {
13781378
remove = false;
13791379
for (size_t j = 0, K = arglist->length(); j < K && !remove; ++j) {
1380-
remove = Eval::eq(key, arglist->value_at_index(j), ctx);
1380+
remove = Eval::eq(key, arglist->value_at_index(j));
13811381
}
13821382
if (!remove) *result << make_pair(key, m->at(key));
13831383
}

listize.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,9 @@ namespace Sass {
7878
return l;
7979
}
8080

81-
Expression* Listize::operator()(Parent_Selector* sel)
82-
{
83-
return 0;
84-
}
85-
8681
Expression* Listize::fallback_impl(AST_Node* n)
8782
{
88-
return static_cast<Expression*>(n);
83+
return dynamic_cast<Expression*>(n);
8984
}
85+
9086
}

listize.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace Sass {
3030
Expression* operator()(Selector_List*);
3131
Expression* operator()(Complex_Selector*);
3232
Expression* operator()(Compound_Selector*);
33-
Expression* operator()(Parent_Selector*);
3433

3534
template <typename U>
3635
Expression* fallback(U x) { return fallback_impl(x); }

0 commit comments

Comments
 (0)