Skip to content

Commit 5aae535

Browse files
committed
Cleanup some allocator code paths
- Remove unused allocator functions - Fix return type of wstring_to_string - Use `sass::ostream` instead of `sass::sstream`
1 parent 1e181d6 commit 5aae535

File tree

13 files changed

+34
-36
lines changed

13 files changed

+34
-36
lines changed

src/backtrace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Sass {
44

55
const sass::string traces_to_string(Backtraces traces, sass::string indent) {
66

7-
sass::sstream ss;
7+
sass::ostream ss;
88
sass::string cwd(File::get_cwd());
99

1010
bool first = true;

src/bind.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace Sass {
5252
}
5353
}
5454
}
55-
sass::sstream msg;
55+
sass::ostream msg;
5656
msg << "wrong number of arguments (" << LA << " for " << LP << ")";
5757
msg << " for `" << name << "'";
5858
return error(msg.str(), as->pstate(), traces);
@@ -189,7 +189,7 @@ namespace Sass {
189189
} else {
190190
if (arglist->length() > LP - ip && !ps->has_rest_parameter()) {
191191
size_t arg_count = (arglist->length() + LA - 1);
192-
sass::sstream msg;
192+
sass::ostream msg;
193193
msg << callee << " takes " << LP;
194194
msg << (LP == 1 ? " argument" : " arguments");
195195
msg << " but " << arg_count;
@@ -229,7 +229,7 @@ namespace Sass {
229229
sass::string param = "$" + unquote(val->value());
230230

231231
if (!param_map.count(param)) {
232-
sass::sstream msg;
232+
sass::ostream msg;
233233
msg << callee << " has no parameter named " << param;
234234
error(msg.str(), a->pstate(), traces);
235235
}
@@ -243,7 +243,7 @@ namespace Sass {
243243

244244
if (a->name().empty()) {
245245
if (env->has_local(p->name())) {
246-
sass::sstream msg;
246+
sass::ostream msg;
247247
msg << "parameter " << p->name()
248248
<< " provided more than once in call to " << callee;
249249
error(msg.str(), a->pstate(), traces);
@@ -258,21 +258,21 @@ namespace Sass {
258258
if (ps->has_rest_parameter()) {
259259
varargs->append(a);
260260
} else {
261-
sass::sstream msg;
261+
sass::ostream msg;
262262
msg << callee << " has no parameter named " << a->name();
263263
error(msg.str(), a->pstate(), traces);
264264
}
265265
}
266266
if (param_map[a->name()]) {
267267
if (param_map[a->name()]->is_rest_parameter()) {
268-
sass::sstream msg;
268+
sass::ostream msg;
269269
msg << "argument " << a->name() << " of " << callee
270270
<< "cannot be used as named argument";
271271
error(msg.str(), a->pstate(), traces);
272272
}
273273
}
274274
if (env->has_local(a->name())) {
275-
sass::sstream msg;
275+
sass::ostream msg;
276276
msg << "parameter " << p->name()
277277
<< "provided more than once in call to " << callee;
278278
error(msg.str(), a->pstate(), traces);

src/context.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ namespace Sass {
334334

335335
// error nicely on ambiguous imp_path
336336
if (resolved.size() > 1) {
337-
sass::sstream msg_stream;
337+
sass::ostream msg_stream;
338338
msg_stream << "It's not clear which file to import for ";
339339
msg_stream << "'@import \"" << imp.imp_path << "\"'." << "\n";
340340
msg_stream << "Candidates:" << "\n";
@@ -423,7 +423,7 @@ namespace Sass {
423423
// create unique path to use as key
424424
sass::string uniq_path = load_path;
425425
if (!only_one && count) {
426-
sass::sstream path_strm;
426+
sass::ostream path_strm;
427427
path_strm << uniq_path << ":" << count;
428428
uniq_path = path_strm.str();
429429
}
@@ -676,7 +676,7 @@ namespace Sass {
676676
{
677677
sass::string map = emitter.render_srcmap(*this);
678678
sass::istream is( map.c_str() );
679-
sass::sstream buffer;
679+
sass::ostream buffer;
680680
base64::encoder E;
681681
E.encode(is, buffer);
682682
sass::string url = "data:application/json;base64," + buffer.str();
@@ -722,7 +722,7 @@ namespace Sass {
722722
void register_function(Context& ctx, Signature sig, Native_Function f, size_t arity, Env* env)
723723
{
724724
Definition* def = make_native_function(sig, f, ctx);
725-
sass::sstream ss;
725+
sass::ostream ss;
726726
ss << def->name() << "[f]" << arity;
727727
def->environment(env);
728728
(*env)[ss.str()] = def;

src/eval.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ namespace Sass {
184184
Number_Obj sass_end = Cast<Number>(high);
185185
// check if units are valid for sequence
186186
if (sass_start->unit() != sass_end->unit()) {
187-
sass::sstream msg; msg << "Incompatible units: '"
187+
sass::ostream msg; msg << "Incompatible units: '"
188188
<< sass_end->unit() << "' and '"
189189
<< sass_start->unit() << "'.";
190190
error(msg.str(), low->pstate(), traces);
@@ -1010,7 +1010,7 @@ namespace Sass {
10101010
if (c->func()) def = c->func()->definition();
10111011

10121012
if (def->is_overload_stub()) {
1013-
sass::sstream ss;
1013+
sass::ostream ss;
10141014
size_t L = args->length();
10151015
// account for rest arguments
10161016
if (args->has_rest_argument() && args->length() > 0) {

src/expand.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ namespace Sass {
531531
Number_Obj sass_end = Cast<Number>(high);
532532
// check if units are valid for sequence
533533
if (sass_start->unit() != sass_end->unit()) {
534-
sass::sstream msg; msg << "Incompatible units: '"
534+
sass::ostream msg; msg << "Incompatible units: '"
535535
<< sass_start->unit() << "' and '"
536536
<< sass_end->unit() << "'.";
537537
error(msg.str(), low->pstate(), traces);
@@ -698,7 +698,7 @@ namespace Sass {
698698

699699
if (compound->length() != 1) {
700700

701-
sass::sstream sels; bool addComma = false;
701+
sass::ostream sels; bool addComma = false;
702702
sels << "Compound selectors may no longer be extended.\n";
703703
sels << "Consider `@extend ";
704704
for (auto sel : compound->elements()) {

src/file.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
# ifdef _MSC_VER
3434
# include <codecvt>
35-
inline static std::string wstring_to_string(const std::wstring& wstr)
35+
inline static Sass::sass::string wstring_to_string(const std::wstring& wstr)
3636
{
3737
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wchar_converter;
3838
return wchar_converter.to_bytes(wstr);
@@ -68,7 +68,7 @@ namespace Sass {
6868
wchar_t wd[wd_len];
6969
wchar_t* pwd = _wgetcwd(wd, wd_len);
7070
if (pwd == NULL) throw Exception::OperationError("cwd gone missing");
71-
sass::string cwd = wstring_to_string(pwd).c_str();
71+
sass::string cwd = wstring_to_string(pwd);
7272
//convert backslashes to forward slashes
7373
replace(cwd.begin(), cwd.end(), '\\', '/');
7474
#endif

src/fn_colors.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ namespace Sass {
104104
if (
105105
string_argument(env["$alpha"])
106106
) {
107-
sass::sstream strm;
107+
sass::ostream strm;
108108
strm << "rgba("
109109
<< (int)c_arg->r() << ", "
110110
<< (int)c_arg->g() << ", "
@@ -579,7 +579,7 @@ namespace Sass {
579579
double b = clip(c->b(), 0.0, 255.0);
580580
double a = clip(c->a(), 0.0, 1.0) * 255.0;
581581

582-
sass::sstream ss;
582+
sass::ostream ss;
583583
ss << '#' << std::setw(2) << std::setfill('0');
584584
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(a, ctx.c_options.precision));
585585
ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(r, ctx.c_options.precision));

src/fn_numbers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ namespace Sass {
154154
if (l) {
155155
double lv = l->value();
156156
if (lv < 1) {
157-
sass::sstream err;
157+
sass::ostream err;
158158
err << "$limit " << lv << " must be greater than or equal to 1 for `random'";
159159
error(err.str(), pstate, traces);
160160
}
161161
bool eq_int = std::fabs(trunc(lv) - lv) < NUMBER_EPSILON;
162162
if (!eq_int) {
163-
sass::sstream err;
163+
sass::ostream err;
164164
err << "Expected $limit to be an integer but got " << lv << " for `random'";
165165
error(err.str(), pstate, traces);
166166
}
@@ -184,7 +184,7 @@ namespace Sass {
184184
Signature unique_id_sig = "unique-id()";
185185
BUILT_IN(unique_id)
186186
{
187-
sass::sstream ss;
187+
sass::ostream ss;
188188
std::uniform_real_distribution<> distributor(0, 4294967296); // 16^8
189189
uint_fast32_t distributed = static_cast<uint_fast32_t>(distributor(rand));
190190
ss << "u" << std::setfill('0') << std::setw(8) << std::hex << distributed;

src/fn_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace Sass {
7171
tmpnr.reduce();
7272
double v = tmpnr.value();
7373
if (!(lo <= v && v <= hi)) {
74-
sass::sstream msg;
74+
sass::ostream msg;
7575
msg << "argument `" << argname << "` of `" << sig << "` must be between ";
7676
msg << lo << " and " << hi;
7777
error(msg.str(), pstate, traces);
@@ -121,7 +121,7 @@ namespace Sass {
121121
SelectorListObj get_arg_sels(const sass::string& argname, Env& env, Signature sig, SourceSpan pstate, Backtraces traces, Context& ctx) {
122122
ExpressionObj exp = ARG(argname, Expression);
123123
if (exp->concrete_type() == Expression::NULL_VAL) {
124-
sass::sstream msg;
124+
sass::ostream msg;
125125
msg << argname << ": null is not a valid selector: it must be a string,\n";
126126
msg << "a list of strings, or a list of lists of strings for `" << function_name(sig) << "'";
127127
error(msg.str(), exp->pstate(), traces);
@@ -136,7 +136,7 @@ namespace Sass {
136136
CompoundSelectorObj get_arg_sel(const sass::string& argname, Env& env, Signature sig, SourceSpan pstate, Backtraces traces, Context& ctx) {
137137
ExpressionObj exp = ARG(argname, Expression);
138138
if (exp->concrete_type() == Expression::NULL_VAL) {
139-
sass::sstream msg;
139+
sass::ostream msg;
140140
msg << argname << ": null is not a string for `" << function_name(sig) << "'";
141141
error(msg.str(), exp->pstate(), traces);
142142
}

src/inspect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ namespace Sass {
570570
// reduce units
571571
n->reduce();
572572

573-
sass::sstream ss;
573+
sass::ostream ss;
574574
ss.precision(opt.precision);
575575
ss << std::fixed << n->value();
576576

@@ -627,7 +627,7 @@ namespace Sass {
627627
void Inspect::operator()(Color_RGBA* c)
628628
{
629629
// output the final token
630-
sass::sstream ss;
630+
sass::ostream ss;
631631

632632
// original color name
633633
// maybe an unknown token
@@ -656,7 +656,7 @@ namespace Sass {
656656
res_name = color_to_name(numval);
657657
}
658658

659-
sass::sstream hexlet;
659+
sass::ostream hexlet;
660660
// dart sass compressed all colors in regular css always
661661
// ruby sass and libsass does it only when not delayed
662662
// since color math is going to be removed, this can go too

0 commit comments

Comments
 (0)