Skip to content

Commit 0fc0777

Browse files
committed
Cleanup and refactor env-stack methods
1 parent 4b12f26 commit 0fc0777

12 files changed

+236
-726
lines changed

src/ast_containers.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ namespace Sass {
315315

316316
bool erase(const K& key)
317317
{
318+
// Would be faster by quite a bit (2% for bolt)
319+
// return elements_.unordered_erase(key) != 0;
318320
return elements_.erase(key) != 0;
319321
}
320322

src/ast_expressions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ namespace Sass {
283283
{
284284
ADD_CONSTREF(EnvKey, name);
285285
ADD_REF(sass::vector<EnvIdx>, vidxs);
286-
ADD_REF(EnvIdx, vidx2);
286+
// ADD_REF(EnvIdx, vidx2);
287287
ADD_CONSTREF(sass::string, ns);
288288
ADD_PROPERTY(bool, withinLoop);
289289
public:

src/ast_statements.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,12 +792,14 @@ namespace Sass {
792792
// The name of the mixin being invoked.
793793
ADD_CONSTREF(EnvKey, name);
794794

795+
ADD_CONSTREF(EnvIdx, midx);
796+
795797
// The block that will be invoked for [ContentRule]s in the mixin
796798
// being invoked, or `null` if this doesn't pass a content block.
797799
ADD_CONSTREF(ContentBlockObj, content);
798800

799801

800-
ADD_PROPERTY(CallableObj, cached); // circular?
802+
// ADD_PROPERTY(CallableObj, cached); // circular?
801803

802804
public:
803805

src/compiler.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,35 @@ namespace Sass {
4141

4242
struct SassValue* get_global(struct SassCompiler* comp, struct SassValue* name)
4343
{
44-
Value& value(Value::unwrap(name));
45-
Compiler& compiler(Compiler::unwrap(comp));
46-
ValueObj rv = compiler.findVariable(
47-
value.assertString(compiler, "name")->getText(), true);
48-
if (rv) rv->refcount += 1;
49-
return rv ? Value::wrap(rv) : sass_make_null();
44+
// Value& value(Value::unwrap(name));
45+
// Compiler& compiler(Compiler::unwrap(comp));
46+
// ValueObj rv = compiler.findVariable(
47+
// value.assertString(compiler, "name")->getText(), true);
48+
// if (rv) rv->refcount += 1;
49+
// return rv ? Value::wrap(rv) : sass_make_null();
50+
return sass_make_null();
5051
}
5152

5253
struct SassValue* get_lexical(struct SassCompiler* comp, struct SassValue* name)
5354
{
54-
Value& value(Value::unwrap(name));
55-
Compiler& compiler(Compiler::unwrap(comp));
56-
ValueObj rv = compiler.findVariable(
57-
value.assertString(compiler, "name")->getText());
58-
if (rv) rv->refcount += 1;
59-
return rv ? Value::wrap(rv) : sass_make_null();
55+
// Value& value(Value::unwrap(name));
56+
// Compiler& compiler(Compiler::unwrap(comp));
57+
// ValueObj rv = compiler.findVariable(
58+
// value.assertString(compiler, "name")->getText());
59+
// if (rv) rv->refcount += 1;
60+
// return rv ? Value::wrap(rv) : sass_make_null();
61+
return sass_make_null();
6062
}
6163

6264
struct SassValue* get_local(struct SassCompiler* comp, struct SassValue* name)
6365
{
64-
Value& value(Value::unwrap(name));
65-
Compiler& compiler(Compiler::unwrap(comp));
66-
ValueObj rv = compiler.findVariable(
67-
value.assertString(compiler, "name")->getText());
68-
if (rv) rv->refcount += 1;
69-
return rv ? Value::wrap(rv) : sass_make_null();
66+
// Value& value(Value::unwrap(name));
67+
// Compiler& compiler(Compiler::unwrap(comp));
68+
// ValueObj rv = compiler.findVariable(
69+
// value.assertString(compiler, "name")->getText());
70+
// if (rv) rv->refcount += 1;
71+
// return rv ? Value::wrap(rv) : sass_make_null();
72+
return sass_make_null();
7073
}
7174

7275
struct SassValue* set_global(struct SassCompiler* comp, struct SassValue* name, struct SassValue* value)

src/compiler.hpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,8 @@ namespace Sass {
6565
// and (custom) functions plus mixins are registered.
6666
EnvRoot varRoot; // Must be after varStack!
6767

68-
// Get the value object for the variable by [name] on runtime.
69-
// If [global] flag is given, we
70-
ValueObj findVariable(const EnvKey& name, bool global = false) {
71-
return varRoot.findVariable(name, global);
72-
}
73-
74-
EnvIdx setVariable(const EnvKey& name, bool guarded, bool global) {
75-
return varRoot.setVariable(name, guarded, global);
76-
}
77-
7868
// Functions only for evaluation phase (C-API functions and eval itself)
79-
CallableObj* findFunction(const EnvKey& name) { return varRoot.findFunction(name); }
69+
// CallableObj* findFunction(const EnvKey& name) { return varRoot.findFunction(name); }
8070

8171
// The current state the compiler is in.
8272
enum SassCompilerState state;

src/environment.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,8 @@ namespace Sass {
153153

154154
if (a->ns().empty()) {
155155

156-
a->vidx2(compiler.varRoot.setVariable(
157-
a->variable(),
158-
a->is_default(),
159-
a->is_global()));
156+
a->vidx2(compiler.varRoot.findVarIdx(
157+
a->variable(), a->ns(), a->is_global()));
160158
assigne = &compiler.varRoot.getVariable(a->vidx2());
161159
if (!result) result = a->value()->accept(this);
162160
compiler.varRoot.setVariable(

0 commit comments

Comments
 (0)