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:
Nicolas B. Pierron 2023-09-20 17:00:11 +00:00
Родитель bf2079b179
Коммит e1112e440c
2 изменённых файлов: 0 добавлений и 32 удалений

Просмотреть файл

@ -17,7 +17,6 @@
#include "js/TypeDecls.h"
#include "js/Utility.h"
#include "util/Text.h"
namespace js {
@ -52,18 +51,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)) {