mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1839396 part 18 - Remove GenericPrinter::putAsciiPrintable. r=mgaudet
`putAsciiPrintable` was added temporarily as a substitute for externalizing the logic done by `QuoteString`, while providing an interface which is as efficient. Now, `EscapePrinter` is used to replace the content of `QuoteString` while providing the same implementation, except that it is based on `put` instead of `putAsciiPrintable`. The `EscapePrinter` already provides the guarantees that are asserted by `putAsciiPrintable`, thus there is no longer any need for it. As this patch set introduced `putAsciiPrintable`, there is not yet any external consumer of it, and `EscapePrinter` should cover all use cases where non-ascii inputs are provided. Differential Revision: https://phabricator.services.mozilla.com/D183760
This commit is contained in:
parent
3d55cd49c2
commit
5364888f45
@ -52,18 +52,6 @@ class JS_PUBLIC_API GenericPrinter {
|
||||
MOZ_CRASH("Use an EscapePrinter to handle all characters");
|
||||
}
|
||||
|
||||
virtual void putAsciiPrintable(mozilla::Span<const JS::Latin1Char> str);
|
||||
virtual void putAsciiPrintable(mozilla::Span<const char16_t> str);
|
||||
|
||||
inline void putAsciiPrintable(const char c) {
|
||||
MOZ_ASSERT(IsAsciiPrintable(c));
|
||||
putChar(c);
|
||||
}
|
||||
inline void putAsciiPrintable(const char16_t c) {
|
||||
MOZ_ASSERT(IsAsciiPrintable(c));
|
||||
putChar(char(c));
|
||||
}
|
||||
|
||||
virtual void putString(JSContext* cx, JSString* str);
|
||||
|
||||
// Prints a formatted string into the buffer.
|
||||
|
@ -61,25 +61,6 @@ void GenericPrinter::put(mozilla::Span<const char16_t> str) {
|
||||
}
|
||||
}
|
||||
|
||||
void GenericPrinter::putAsciiPrintable(
|
||||
mozilla::Span<const JS::Latin1Char> str) {
|
||||
if (!str.Length()) {
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
for (char c: str) {
|
||||
MOZ_ASSERT(IsAsciiPrintable(c));
|
||||
}
|
||||
#endif
|
||||
put(reinterpret_cast<const char*>(&str[0]), str.Length());
|
||||
}
|
||||
|
||||
void GenericPrinter::putAsciiPrintable(mozilla::Span<const char16_t> str) {
|
||||
for (char16_t c: str) {
|
||||
putAsciiPrintable(c);
|
||||
}
|
||||
}
|
||||
|
||||
void GenericPrinter::putString(JSContext* cx, JSString* str) {
|
||||
StringSegmentRange iter(cx);
|
||||
if (!iter.init(str)) {
|
||||
|
Loading…
Reference in New Issue
Block a user