mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 06:35:06 +00:00
LibJS: Use new format functions everywhere
This changes the remaining uses of the following functions across LibJS: - String::format() => String::formatted() - dbg() => dbgln() - printf() => out(), outln() - fprintf() => warnln() I also removed the relevant 'LogStream& operator<<' overloads as they're not needed anymore.
This commit is contained in:
parent
2313e58393
commit
5eb1f752ab
15 changed files with 151 additions and 171 deletions
|
@ -118,7 +118,8 @@ String Value::to_string_without_side_effects() const
|
|||
return is_negative_infinity() ? "-Infinity" : "Infinity";
|
||||
if (is_integer())
|
||||
return String::number(as_i32());
|
||||
return String::format("%.4f", m_value.as_double);
|
||||
// FIXME: This should be more sophisticated: don't cut off decimals, don't include trailing zeros
|
||||
return String::formatted("{:.4}", m_value.as_double);
|
||||
case Type::String:
|
||||
return m_value.as_string->string();
|
||||
case Type::Symbol:
|
||||
|
@ -162,7 +163,8 @@ String Value::to_string(GlobalObject& global_object, bool legacy_null_to_empty_s
|
|||
return is_negative_infinity() ? "-Infinity" : "Infinity";
|
||||
if (is_integer())
|
||||
return String::number(as_i32());
|
||||
return String::format("%.4f", m_value.as_double);
|
||||
// FIXME: This should be more sophisticated: don't cut off decimals, don't include trailing zeros
|
||||
return String::formatted("{:.4}", m_value.as_double);
|
||||
case Type::String:
|
||||
return m_value.as_string->string();
|
||||
case Type::Symbol:
|
||||
|
@ -237,7 +239,7 @@ Object* Value::to_object(GlobalObject& global_object) const
|
|||
case Type::Object:
|
||||
return &const_cast<Object&>(as_object());
|
||||
default:
|
||||
dbg() << "Dying because I can't to_object() on " << *this;
|
||||
dbgln("Dying because I can't to_object() on {}", *this);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
@ -822,11 +824,6 @@ Value ordinary_has_instance(GlobalObject& global_object, Value lhs, Value rhs)
|
|||
}
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, const Value& value)
|
||||
{
|
||||
return stream << (value.is_empty() ? "<empty>" : value.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
bool same_value(Value lhs, Value rhs)
|
||||
{
|
||||
if (lhs.type() != rhs.type())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue