зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1583109 - Use StringJoin(Append) where easily possible. r=nika
Bug 1583109 introduced new function templates StringJoin and StringJoinAppend. These are now used to replace several custom loops across the codebase that implement string-joining algorithms to simplify the code. Differential Revision: https://phabricator.services.mozilla.com/D98750
This commit is contained in:
Родитель
ae44ae4664
Коммит
9758d919eb
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "ExpandedPrincipal.h"
|
||||
#include "nsIClassInfoImpl.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "mozilla/Base64.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -61,16 +62,14 @@ already_AddRefed<ExpandedPrincipal> ExpandedPrincipal::Create(
|
|||
|
||||
nsAutoCString origin;
|
||||
origin.AssignLiteral("[Expanded Principal [");
|
||||
for (size_t i = 0; i < ep->mPrincipals.Length(); ++i) {
|
||||
if (i != 0) {
|
||||
origin.AppendLiteral(", ");
|
||||
}
|
||||
|
||||
StringJoinAppend(
|
||||
origin, ", "_ns, ep->mPrincipals,
|
||||
[](nsACString& dest, const nsCOMPtr<nsIPrincipal>& principal) {
|
||||
nsAutoCString subOrigin;
|
||||
DebugOnly<nsresult> rv = ep->mPrincipals.ElementAt(i)->GetOrigin(subOrigin);
|
||||
DebugOnly<nsresult> rv = principal->GetOrigin(subOrigin);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
origin.Append(subOrigin);
|
||||
}
|
||||
dest.Append(subOrigin);
|
||||
});
|
||||
origin.AppendLiteral("]]");
|
||||
|
||||
ep->FinishInit(origin, aAttrs);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/dom/BrowsingContextGroup.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -19,16 +20,11 @@ namespace syncedcontext {
|
|||
template <typename Context>
|
||||
nsCString FormatValidationError(IndexSet aFailedFields, const char* prefix) {
|
||||
MOZ_ASSERT(!aFailedFields.isEmpty());
|
||||
nsCString error(prefix);
|
||||
bool first = true;
|
||||
for (auto idx : aFailedFields) {
|
||||
if (!first) {
|
||||
error.Append(", ");
|
||||
}
|
||||
first = false;
|
||||
error.Append(Context::FieldIndexToName(idx));
|
||||
}
|
||||
return error;
|
||||
return nsDependentCString{prefix} +
|
||||
StringJoin(", "_ns, aFailedFields,
|
||||
[](nsACString& dest, const auto& idx) {
|
||||
dest.Append(Context::FieldIndexToName(idx));
|
||||
});
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsContentUtils.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "mozilla/ConsoleTimelineMarker.h"
|
||||
#include "mozilla/TimestampTimelineMarker.h"
|
||||
|
||||
|
@ -2058,12 +2059,9 @@ static void ComposeAndStoreGroupName(JSContext* aCx,
|
|||
const Sequence<JS::Value>& aData,
|
||||
nsAString& aName,
|
||||
nsTArray<nsString>* aGroupStack) {
|
||||
for (uint32_t i = 0; i < aData.Length(); ++i) {
|
||||
if (i != 0) {
|
||||
aName.AppendLiteral(" ");
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> value(aCx, aData[i]);
|
||||
StringJoinAppend(
|
||||
aName, u" "_ns, aData, [aCx](nsAString& dest, const JS::Value& valueRef) {
|
||||
JS::Rooted<JS::Value> value(aCx, valueRef);
|
||||
JS::Rooted<JSString*> jsString(aCx, JS::ToString(aCx, value));
|
||||
if (!jsString) {
|
||||
return;
|
||||
|
@ -2074,8 +2072,8 @@ static void ComposeAndStoreGroupName(JSContext* aCx,
|
|||
return;
|
||||
}
|
||||
|
||||
aName.Append(string);
|
||||
}
|
||||
dest.Append(string);
|
||||
});
|
||||
|
||||
aGroupStack->AppendElement(aName);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIMultiplexInputStream.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsRFPService.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -320,16 +321,13 @@ size_t MultipartBlobImpl::GetAllocationSize(
|
|||
void MultipartBlobImpl::GetBlobImplType(nsAString& aBlobImplType) const {
|
||||
aBlobImplType.AssignLiteral("MultipartBlobImpl[");
|
||||
|
||||
for (uint32_t i = 0; i < mBlobImpls.Length(); ++i) {
|
||||
if (i != 0) {
|
||||
aBlobImplType.AppendLiteral(", ");
|
||||
}
|
||||
|
||||
StringJoinAppend(aBlobImplType, u", "_ns, mBlobImpls,
|
||||
[](nsAString& dest, BlobImpl* subBlobImpl) {
|
||||
nsAutoString blobImplType;
|
||||
mBlobImpls[i]->GetBlobImplType(blobImplType);
|
||||
subBlobImpl->GetBlobImplType(blobImplType);
|
||||
|
||||
aBlobImplType.Append(blobImplType);
|
||||
}
|
||||
dest.Append(blobImplType);
|
||||
});
|
||||
|
||||
aBlobImplType.AppendLiteral("]");
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "FileSystemRootDirectoryReader.h"
|
||||
#include "mozilla/dom/FileSystemUtils.h"
|
||||
#include "CallbackRunnables.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
|
@ -124,12 +125,10 @@ void FileSystemRootDirectoryEntry::GetInternal(
|
|||
|
||||
// Let's recreate a path without the first directory.
|
||||
nsAutoString path;
|
||||
for (uint32_t i = 1, len = parts.Length(); i < len; ++i) {
|
||||
path.Append(parts[i]);
|
||||
if (i < len - 1) {
|
||||
path.AppendLiteral(FILESYSTEM_DOM_PATH_SEPARATOR_LITERAL);
|
||||
}
|
||||
}
|
||||
StringJoinAppend(
|
||||
path,
|
||||
NS_LITERAL_STRING_FROM_CSTRING(FILESYSTEM_DOM_PATH_SEPARATOR_LITERAL),
|
||||
Span{parts}.From(1));
|
||||
|
||||
auto* directoryEntry = static_cast<FileSystemDirectoryEntry*>(entry.get());
|
||||
directoryEntry->GetInternal(path, aFlag, aSuccessCallback, aErrorCallback,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "ThreadLocal.h"
|
||||
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
namespace mozilla::dom::indexedDB {
|
||||
|
||||
|
@ -106,17 +107,12 @@ LoggingString::LoggingString(const IDBTransaction& aTransaction)
|
|||
: nsAutoCString(kOpenBracket) {
|
||||
constexpr auto kCommaSpace = ", "_ns;
|
||||
|
||||
const nsTArray<nsString>& stores = aTransaction.ObjectStoreNamesInternal();
|
||||
|
||||
for (uint32_t count = stores.Length(), index = 0; index < count; index++) {
|
||||
Append(kQuote);
|
||||
AppendUTF16toUTF8(stores[index], *this);
|
||||
Append(kQuote);
|
||||
|
||||
if (index != count - 1) {
|
||||
Append(kCommaSpace);
|
||||
}
|
||||
}
|
||||
StringJoinAppend(*this, kCommaSpace, aTransaction.ObjectStoreNamesInternal(),
|
||||
[](nsACString& dest, const auto& store) {
|
||||
dest.Append(kQuote);
|
||||
AppendUTF16toUTF8(store, dest);
|
||||
dest.Append(kQuote);
|
||||
});
|
||||
|
||||
Append(kCloseBracket);
|
||||
Append(kCommaSpace);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsDOMString.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "VideoUtils.h"
|
||||
|
@ -1194,12 +1195,10 @@ template <class Type>
|
|||
static nsCString ToCString(const Sequence<Type>& aSequence) {
|
||||
nsCString str;
|
||||
str.AppendLiteral("[");
|
||||
for (size_t i = 0; i < aSequence.Length(); i++) {
|
||||
if (i != 0) {
|
||||
str.AppendLiteral(",");
|
||||
}
|
||||
str.Append(ToCString(aSequence[i]));
|
||||
}
|
||||
StringJoinAppend(str, ","_ns, aSequence,
|
||||
[](nsACString& dest, const Type& element) {
|
||||
dest.Append(ToCString(element));
|
||||
});
|
||||
str.AppendLiteral("]");
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "GMPUtils.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "CDMStorageIdProvider.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
|
@ -105,15 +106,10 @@ class CDMShmemBuffer : public CDMBuffer {
|
|||
void operator=(const CDMShmemBuffer&);
|
||||
};
|
||||
|
||||
static nsCString ToString(const nsTArray<ipc::Shmem>& aBuffers) {
|
||||
nsCString s;
|
||||
for (const ipc::Shmem& shmem : aBuffers) {
|
||||
if (!s.IsEmpty()) {
|
||||
s.AppendLiteral(",");
|
||||
}
|
||||
static auto ToString(const nsTArray<ipc::Shmem>& aBuffers) {
|
||||
return StringJoin(","_ns, aBuffers, [](auto& s, const ipc::Shmem& shmem) {
|
||||
s.AppendInt(static_cast<uint32_t>(shmem.Size<uint8_t>()));
|
||||
}
|
||||
return s;
|
||||
});
|
||||
}
|
||||
|
||||
cdm::Buffer* ChromiumCDMChild::Allocate(uint32_t aCapacity) {
|
||||
|
@ -272,19 +268,14 @@ void ChromiumCDMChild::OnSessionMessage(const char* aSessionId,
|
|||
static_cast<uint32_t>(aMessageType), message);
|
||||
}
|
||||
|
||||
static nsCString ToString(const cdm::KeyInformation* aKeysInfo,
|
||||
static auto ToString(const cdm::KeyInformation* aKeysInfo,
|
||||
uint32_t aKeysInfoCount) {
|
||||
nsCString str;
|
||||
for (uint32_t i = 0; i < aKeysInfoCount; i++) {
|
||||
if (!str.IsEmpty()) {
|
||||
str.AppendLiteral(",");
|
||||
}
|
||||
const cdm::KeyInformation& key = aKeysInfo[i];
|
||||
return StringJoin(","_ns, Span{aKeysInfo, aKeysInfoCount},
|
||||
[](auto& str, const cdm::KeyInformation& key) {
|
||||
str.Append(ToHexString(key.key_id, key.key_id_size));
|
||||
str.AppendLiteral("=");
|
||||
str.AppendInt(key.status);
|
||||
}
|
||||
return str;
|
||||
});
|
||||
}
|
||||
|
||||
void ChromiumCDMChild::OnSessionKeysChange(const char* aSessionId,
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "nsDebugImpl.h"
|
||||
#include "nsExceptionHandler.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "prio.h"
|
||||
#ifdef XP_WIN
|
||||
|
@ -473,16 +474,10 @@ GMPChild::MakeCDMHostVerificationPaths() {
|
|||
return paths;
|
||||
}
|
||||
|
||||
static nsCString ToCString(
|
||||
const nsTArray<std::pair<nsCString, nsCString>>& aPairs) {
|
||||
nsCString result;
|
||||
for (const auto& p : aPairs) {
|
||||
if (!result.IsEmpty()) {
|
||||
result.AppendLiteral(",");
|
||||
}
|
||||
result.Append(nsPrintfCString("(%s,%s)", p.first.get(), p.second.get()));
|
||||
}
|
||||
return result;
|
||||
static auto ToCString(const nsTArray<std::pair<nsCString, nsCString>>& aPairs) {
|
||||
return StringJoin(","_ns, aPairs, [](nsACString& dest, const auto& p) {
|
||||
dest.AppendPrintf("(%s,%s)", p.first.get(), p.second.get());
|
||||
});
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult GMPChild::AnswerStartPlugin(const nsString& aAdapter) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsXPCOMPrivate.h"
|
||||
#include "runnable_utils.h"
|
||||
|
||||
|
@ -213,18 +214,14 @@ struct GMPCapabilityAndVersion {
|
|||
s.AppendLiteral(" version=");
|
||||
s.Append(mVersion);
|
||||
s.AppendLiteral(" tags=[");
|
||||
nsCString tags;
|
||||
for (const GMPCapability& cap : mCapabilities) {
|
||||
if (!tags.IsEmpty()) {
|
||||
tags.AppendLiteral(" ");
|
||||
}
|
||||
StringJoinAppend(s, " "_ns, mCapabilities,
|
||||
[](auto& tags, const GMPCapability& cap) {
|
||||
tags.Append(cap.mAPIName);
|
||||
for (const nsCString& tag : cap.mAPITags) {
|
||||
tags.AppendLiteral(":");
|
||||
tags.Append(tag);
|
||||
}
|
||||
}
|
||||
s.Append(tags);
|
||||
});
|
||||
s.AppendLiteral("]");
|
||||
return s;
|
||||
}
|
||||
|
@ -237,23 +234,19 @@ struct GMPCapabilityAndVersion {
|
|||
StaticMutex sGMPCapabilitiesMutex;
|
||||
StaticAutoPtr<nsTArray<GMPCapabilityAndVersion>> sGMPCapabilities;
|
||||
|
||||
static nsCString GMPCapabilitiesToString() {
|
||||
nsCString s;
|
||||
for (const GMPCapabilityAndVersion& gmp : *sGMPCapabilities) {
|
||||
if (!s.IsEmpty()) {
|
||||
s.AppendLiteral(", ");
|
||||
}
|
||||
s.Append(gmp.ToString());
|
||||
}
|
||||
return s;
|
||||
static auto GMPCapabilitiesToString() {
|
||||
return StringJoin(", "_ns, *sGMPCapabilities,
|
||||
[](nsACString& dest, const GMPCapabilityAndVersion& gmp) {
|
||||
dest.Append(gmp.ToString());
|
||||
});
|
||||
}
|
||||
|
||||
/* static */
|
||||
void GeckoMediaPluginServiceChild::UpdateGMPCapabilities(
|
||||
nsTArray<GMPCapabilityData>&& aCapabilities) {
|
||||
{
|
||||
// The mutex should unlock before sending the "gmp-changed" observer service
|
||||
// notification.
|
||||
// The mutex should unlock before sending the "gmp-changed" observer
|
||||
// service notification.
|
||||
StaticMutexAutoLock lock(sGMPCapabilitiesMutex);
|
||||
if (!sGMPCapabilities) {
|
||||
sGMPCapabilities = new nsTArray<GMPCapabilityAndVersion>();
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsIEventTarget.h"
|
||||
#include "nsLiteralString.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsTLiteralString.h"
|
||||
|
@ -966,18 +967,9 @@ inline auto AnonymizedOriginString(const nsACString& aOriginString) {
|
|||
|
||||
template <typename T>
|
||||
void StringifyTableKeys(const T& aTable, nsACString& aResult) {
|
||||
bool first = true;
|
||||
for (auto iter = aTable.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
aResult.Append(", "_ns);
|
||||
}
|
||||
|
||||
const auto& key = iter.Get()->GetKey();
|
||||
|
||||
aResult.Append(key);
|
||||
}
|
||||
StringJoinAppend(
|
||||
aResult, ", "_ns, aTable,
|
||||
[](nsACString& dest, const auto& entry) { dest.Append(entry.GetKey()); });
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
|
|
@ -1085,13 +1085,10 @@ void nsCSPDirective::toString(nsAString& outStr) const {
|
|||
outStr.AppendLiteral(" ");
|
||||
|
||||
// Append srcs
|
||||
uint32_t length = mSrcs.Length();
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
mSrcs[i]->toString(outStr);
|
||||
if (i != (length - 1)) {
|
||||
outStr.AppendLiteral(" ");
|
||||
}
|
||||
}
|
||||
StringJoinAppend(outStr, u" "_ns, mSrcs,
|
||||
[](nsAString& dest, nsCSPBaseSrc* cspBaseSrc) {
|
||||
cspBaseSrc->toString(dest);
|
||||
});
|
||||
}
|
||||
|
||||
void nsCSPDirective::toDomCSPStruct(mozilla::dom::CSP& outCSP) const {
|
||||
|
@ -1474,13 +1471,10 @@ bool nsCSPPolicy::allows(nsContentPolicyType aContentType,
|
|||
}
|
||||
|
||||
void nsCSPPolicy::toString(nsAString& outStr) const {
|
||||
uint32_t length = mDirectives.Length();
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
mDirectives[i]->toString(outStr);
|
||||
if (i != (length - 1)) {
|
||||
outStr.AppendLiteral("; ");
|
||||
}
|
||||
}
|
||||
StringJoinAppend(outStr, u"; "_ns, mDirectives,
|
||||
[](nsAString& dest, nsCSPDirective* cspDirective) {
|
||||
cspDirective->toString(dest);
|
||||
});
|
||||
}
|
||||
|
||||
void nsCSPPolicy::toDomCSPStruct(mozilla::dom::CSP& outCSP) const {
|
||||
|
|
|
@ -631,19 +631,18 @@ static void LogPrincipal(nsIPrincipal* aPrincipal,
|
|||
}
|
||||
if (aPrincipal->GetIsExpandedPrincipal()) {
|
||||
nsCOMPtr<nsIExpandedPrincipal> expanded(do_QueryInterface(aPrincipal));
|
||||
const nsTArray<nsCOMPtr<nsIPrincipal>>& allowList = expanded->AllowList();
|
||||
nsAutoCString origin;
|
||||
origin.AssignLiteral("[Expanded Principal [");
|
||||
for (size_t i = 0; i < allowList.Length(); ++i) {
|
||||
if (i != 0) {
|
||||
origin.AppendLiteral(", ");
|
||||
}
|
||||
|
||||
StringJoinAppend(origin, ", "_ns, expanded->AllowList(),
|
||||
[](nsACString& dest, nsIPrincipal* principal) {
|
||||
nsAutoCString subOrigin;
|
||||
DebugOnly<nsresult> rv = allowList.ElementAt(i)->GetOrigin(subOrigin);
|
||||
DebugOnly<nsresult> rv =
|
||||
principal->GetOrigin(subOrigin);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
origin.Append(subOrigin);
|
||||
}
|
||||
dest.Append(subOrigin);
|
||||
});
|
||||
|
||||
origin.AppendLiteral("]]");
|
||||
|
||||
MOZ_LOG(sCSMLog, LogLevel::Debug,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "nsError.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWhitespaceTokenizer.h"
|
||||
#include "SVGContentUtils.h"
|
||||
|
@ -23,17 +24,7 @@ nsresult SVGStringList::CopyFrom(const SVGStringList& rhs) {
|
|||
}
|
||||
|
||||
void SVGStringList::GetValue(nsAString& aValue) const {
|
||||
aValue.Truncate();
|
||||
uint32_t last = mStrings.Length() - 1;
|
||||
for (uint32_t i = 0; i < mStrings.Length(); ++i) {
|
||||
aValue.Append(mStrings[i]);
|
||||
if (i != last) {
|
||||
if (mIsCommaSeparated) {
|
||||
aValue.Append(',');
|
||||
}
|
||||
aValue.Append(' ');
|
||||
}
|
||||
}
|
||||
aValue = StringJoin(mIsCommaSeparated ? u", "_ns : u" "_ns, mStrings);
|
||||
}
|
||||
|
||||
nsresult SVGStringList::SetValue(const nsAString& aValue) {
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
#include "nsJSUtils.h"
|
||||
#include "nsLiteralString.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsTLiteralString.h"
|
||||
|
@ -424,19 +425,14 @@ void WorkerGlobalScope::ImportScripts(JSContext* aCx,
|
|||
|
||||
{
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
nsCString urls;
|
||||
if (profiler_can_accept_markers()) {
|
||||
const uint32_t urlCount = aScriptURLs.Length();
|
||||
if (urlCount) {
|
||||
CopyUTF16toUTF8(aScriptURLs[0], urls);
|
||||
for (uint32_t index = 1; index < urlCount; index++) {
|
||||
urls.AppendLiteral(",");
|
||||
urls.Append(NS_ConvertUTF16toUTF8(aScriptURLs[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
AUTO_PROFILER_MARKER_TEXT("ImportScripts", JS, MarkerStack::Capture(),
|
||||
urls);
|
||||
AUTO_PROFILER_MARKER_TEXT(
|
||||
"ImportScripts", JS, MarkerStack::Capture(),
|
||||
profiler_can_accept_markers()
|
||||
? StringJoin(","_ns, aScriptURLs,
|
||||
[](nsACString& dest, const auto& scriptUrl) {
|
||||
AppendUTF16toUTF8(scriptUrl, dest);
|
||||
})
|
||||
: nsAutoCString{});
|
||||
#endif
|
||||
workerinternals::Load(mWorkerPrivate, std::move(stack), aScriptURLs,
|
||||
WorkerScript, aRv);
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
#include "txIXPathContext.h"
|
||||
#include "txNodeSet.h"
|
||||
|
||||
#ifdef TX_TO_STRING
|
||||
# include "nsReadableUtils.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This class represents a FunctionCall as defined by the XSL Working Draft
|
||||
**/
|
||||
|
@ -98,12 +102,9 @@ bool FunctionCall::argsSensitiveTo(ContextSensitivity aContext) {
|
|||
void FunctionCall::toString(nsAString& aDest) {
|
||||
appendName(aDest);
|
||||
aDest.AppendLiteral("(");
|
||||
for (uint32_t i = 0; i < mParams.Length(); ++i) {
|
||||
if (i != 0) {
|
||||
aDest.Append(char16_t(','));
|
||||
}
|
||||
mParams[i]->toString(aDest);
|
||||
}
|
||||
StringJoinAppend(
|
||||
aDest, u","_ns, mParams,
|
||||
[](nsAString& dest, const auto& param) { param->toString(dest); });
|
||||
aDest.Append(char16_t(')'));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
#include "txIXPathContext.h"
|
||||
#include "txNodeSet.h"
|
||||
|
||||
#ifdef TX_TO_STRING
|
||||
# include "nsReadableUtils.h"
|
||||
#endif
|
||||
|
||||
//-------------/
|
||||
//- UnionExpr -/
|
||||
//-------------/
|
||||
|
@ -74,11 +78,8 @@ bool UnionExpr::isSensitiveTo(ContextSensitivity aContext) {
|
|||
}
|
||||
|
||||
#ifdef TX_TO_STRING
|
||||
void UnionExpr::toString(nsAString& dest) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < mExpressions.Length(); ++i) {
|
||||
if (i > 0) dest.AppendLiteral(" | ");
|
||||
mExpressions[i]->toString(dest);
|
||||
}
|
||||
void UnionExpr::toString(nsAString& aDest) {
|
||||
StringJoinAppend(aDest, u" | "_ns, mExpressions,
|
||||
[](nsAString& dest, Expr* expr) { expr->toString(dest); });
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
#include "txExprResult.h"
|
||||
#include "txSingleNodeContext.h"
|
||||
|
||||
#ifdef TX_TO_STRING
|
||||
# include "nsReadableUtils.h"
|
||||
#endif
|
||||
|
||||
nsresult txUnionNodeTest::matches(const txXPathNode& aNode,
|
||||
txIMatchContext* aContext, bool& aMatched) {
|
||||
uint32_t i, len = mNodeTests.Length();
|
||||
|
@ -45,12 +49,11 @@ bool txUnionNodeTest::isSensitiveTo(Expr::ContextSensitivity aContext) {
|
|||
#ifdef TX_TO_STRING
|
||||
void txUnionNodeTest::toString(nsAString& aDest) {
|
||||
aDest.Append('(');
|
||||
for (uint32_t i = 0; i < mNodeTests.Length(); ++i) {
|
||||
if (i != 0) {
|
||||
aDest.AppendLiteral(" | ");
|
||||
}
|
||||
mNodeTests[i]->toString(aDest);
|
||||
}
|
||||
|
||||
StringJoinAppend(
|
||||
aDest, u" | "_ns, mNodeTests,
|
||||
[](nsAString& dest, txNodeTest* nodeTest) { nodeTest->toString(dest); });
|
||||
|
||||
aDest.Append(')');
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
#include "nsWhitespaceTokenizer.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
#ifdef TX_TO_STRING
|
||||
# include "nsReadableUtils.h"
|
||||
#endif
|
||||
|
||||
using mozilla::UniquePtr;
|
||||
using mozilla::Unused;
|
||||
using mozilla::WrapUnique;
|
||||
|
@ -72,10 +76,9 @@ void txUnionPattern::toString(nsAString& aDest) {
|
|||
# ifdef DEBUG
|
||||
aDest.AppendLiteral("txUnionPattern{");
|
||||
# endif
|
||||
for (uint32_t i = 0; i < mLocPathPatterns.Length(); ++i) {
|
||||
if (i != 0) aDest.AppendLiteral(" | ");
|
||||
mLocPathPatterns[i]->toString(aDest);
|
||||
}
|
||||
StringJoinAppend(
|
||||
aDest, u" | "_ns, mLocPathPatterns,
|
||||
[](nsAString& dest, txPattern* pattern) { pattern->toString(dest); });
|
||||
# ifdef DEBUG
|
||||
aDest.Append(char16_t('}'));
|
||||
# endif
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "nsAtom.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -276,16 +277,11 @@ class FontFamilyList {
|
|||
|
||||
void ToString(nsACString& aFamilyList, bool aQuotes = true,
|
||||
bool aIncludeDefault = false) const {
|
||||
const nsTArray<FontFamilyName>& names = mFontlist->mNames;
|
||||
aFamilyList.Truncate();
|
||||
uint32_t len = names.Length();
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
if (i != 0) {
|
||||
aFamilyList.Append(',');
|
||||
}
|
||||
const FontFamilyName& name = names[i];
|
||||
name.AppendToString(aFamilyList, aQuotes);
|
||||
}
|
||||
aFamilyList =
|
||||
StringJoin(","_ns, mFontlist->mNames,
|
||||
[aQuotes](nsACString& dst, const FontFamilyName& name) {
|
||||
name.AppendToString(dst, aQuotes);
|
||||
});
|
||||
if (aIncludeDefault && mDefaultFontType != StyleGenericFontFamily::None) {
|
||||
if (!aFamilyList.IsEmpty()) {
|
||||
aFamilyList.Append(',');
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "MainThreadUtils.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/IntegerRange.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
@ -28,6 +29,7 @@
|
|||
#include "nsIOutputStream.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsXPCOMPrivate.h"
|
||||
|
@ -375,12 +377,11 @@ void Logger::CaptureFrame(ICallFrame* aCallFrame, IUnknown* aTargetInterface,
|
|||
hr = aCallFrame->GetParam(arrayData->mLengthParamIndex, &lengthParam);
|
||||
if (SUCCEEDED(hr)) {
|
||||
line.AppendLiteral("{ ");
|
||||
for (LONG i = 0; i < *lengthParam.plVal; ++i) {
|
||||
StringJoinAppend(line, ", "_ns,
|
||||
mozilla::IntegerRange<LONG>(0, *lengthParam.plVal),
|
||||
[this, ¶mValue](nsACString& line, const LONG i) {
|
||||
VariantToString(paramValue, line, i);
|
||||
if (i < *lengthParam.plVal - 1) {
|
||||
line.AppendLiteral(", ");
|
||||
}
|
||||
}
|
||||
});
|
||||
line.AppendLiteral(" }");
|
||||
} else {
|
||||
line.AppendPrintf("(GetParam failed with HRESULT 0x%08X)", hr);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "nsIWebProgressListener.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
@ -606,14 +607,10 @@ bool UrlClassifierCommon::IsCryptominingClassificationFlag(uint32_t aFlag) {
|
|||
|
||||
void UrlClassifierCommon::TablesToString(const nsTArray<nsCString>& aList,
|
||||
nsACString& aString) {
|
||||
// Truncate and append rather than assigning because that's more efficient if
|
||||
// aString is an nsAutoCString.
|
||||
aString.Truncate();
|
||||
|
||||
for (const nsCString& table : aList) {
|
||||
if (!aString.IsEmpty()) {
|
||||
aString.Append(",");
|
||||
}
|
||||
aString.Append(table);
|
||||
}
|
||||
StringJoinAppend(aString, ","_ns, aList);
|
||||
}
|
||||
|
||||
uint32_t UrlClassifierCommon::TablesToClassificationFlags(
|
||||
|
|
|
@ -546,14 +546,7 @@ void nsNSSCertificate::GetSubjectAltNames() {
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsNSSCertificate::GetSubjectAltNames(nsAString& _subjectAltNames) {
|
||||
_subjectAltNames.Truncate();
|
||||
|
||||
for (auto altName : mSubjectAltNames) {
|
||||
if (!_subjectAltNames.IsEmpty()) {
|
||||
_subjectAltNames.Append(',');
|
||||
}
|
||||
_subjectAltNames.Append(altName);
|
||||
}
|
||||
_subjectAltNames = StringJoin(u","_ns, mSubjectAltNames);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "Helpers.h"
|
||||
#include "mozIStorageError.h"
|
||||
#include "prio.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsNavHistory.h"
|
||||
#include "mozilla/Base64.h"
|
||||
|
@ -364,14 +365,12 @@ nsresult TokenizeQueryString(const nsACString& aQuery,
|
|||
void TokensToQueryString(const nsTArray<QueryKeyValuePair>& aTokens,
|
||||
nsACString& aQuery) {
|
||||
aQuery = "place:"_ns;
|
||||
for (uint32_t i = 0; i < aTokens.Length(); i++) {
|
||||
if (i > 0) {
|
||||
aQuery.Append("&");
|
||||
}
|
||||
aQuery.Append(aTokens[i].key);
|
||||
aQuery.AppendLiteral("=");
|
||||
aQuery.Append(aTokens[i].value);
|
||||
}
|
||||
StringJoinAppend(aQuery, "&"_ns, aTokens,
|
||||
[](nsACString& dst, const QueryKeyValuePair& token) {
|
||||
dst.Append(token.key);
|
||||
dst.AppendLiteral("=");
|
||||
dst.Append(token.value);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace places
|
||||
|
|
|
@ -5,24 +5,25 @@
|
|||
|
||||
#include "ChunkSet.h"
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace safebrowsing {
|
||||
|
||||
const size_t ChunkSet::IO_BUFFER_SIZE;
|
||||
|
||||
nsresult ChunkSet::Serialize(nsACString& aChunkStr) {
|
||||
// Truncate and append rather than assigning because that's more efficient if
|
||||
// aString is an nsAutoCString.
|
||||
aChunkStr.Truncate();
|
||||
for (const Range& range : mRanges) {
|
||||
if (&range != &mRanges[0]) {
|
||||
aChunkStr.Append(',');
|
||||
}
|
||||
|
||||
aChunkStr.AppendInt((int32_t)range.Begin());
|
||||
StringJoinAppend(aChunkStr, ","_ns, mRanges,
|
||||
[](nsACString& dst, const Range& range) {
|
||||
dst.AppendInt((int32_t)range.Begin());
|
||||
if (range.Begin() != range.End()) {
|
||||
aChunkStr.Append('-');
|
||||
aChunkStr.AppendInt((int32_t)range.End());
|
||||
}
|
||||
dst.Append('-');
|
||||
dst.AppendInt((int32_t)range.End());
|
||||
}
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1428,13 +1428,7 @@ nsresult nsUrlClassifierLookupCallback::HandleResults() {
|
|||
mDBService->CacheCompletions(mCacheResults);
|
||||
mCacheResults.Clear();
|
||||
|
||||
nsAutoCString tableStr;
|
||||
for (uint32_t i = 0; i < tables.Length(); i++) {
|
||||
if (i != 0) tableStr.Append(',');
|
||||
tableStr.Append(tables[i]);
|
||||
}
|
||||
|
||||
return mCallback->HandleEvent(tableStr);
|
||||
return mCallback->HandleEvent(StringJoin(","_ns, tables));
|
||||
}
|
||||
|
||||
nsresult nsUrlClassifierLookupCallback::CacheMisses() {
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ProxyUtils.h"
|
||||
|
||||
#include "mozilla/IntegerRange.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "prnetdb.h"
|
||||
#include "prtypes.h"
|
||||
|
@ -19,17 +22,14 @@ namespace system {
|
|||
static void NormalizeAddr(const nsACString& aAddr, nsCString& aNormalized) {
|
||||
nsTArray<nsCString> addr;
|
||||
ParseString(aAddr, '.', addr);
|
||||
aNormalized = "";
|
||||
for (uint32_t i = 0; i < 4; ++i) {
|
||||
if (i != 0) {
|
||||
aNormalized.AppendLiteral(".");
|
||||
}
|
||||
aNormalized = StringJoin("."_ns, IntegerRange(4),
|
||||
[&addr](nsACString& dst, const int i) {
|
||||
if (i < addr.Length()) {
|
||||
aNormalized.Append(addr[i]);
|
||||
dst.Append(addr[i]);
|
||||
} else {
|
||||
aNormalized.AppendLiteral("0");
|
||||
}
|
||||
dst.Append('0');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static PRUint32 MaskIPv4Addr(PRUint32 aAddr, uint16_t aMaskLen) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "nsIMutableArray.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "nsIStringEnumerator.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
using mozilla::dom::ContentChild;
|
||||
using mozilla::dom::HandlerInfo;
|
||||
|
@ -135,22 +136,10 @@ static inline void CopyHanderInfoTonsIHandlerInfo(
|
|||
possibleHandlers->AppendElement(preferredApp);
|
||||
|
||||
if (info.isMIMEInfo()) {
|
||||
const auto& fileExtensions = info.extensions();
|
||||
bool first = true;
|
||||
nsAutoCString extensionsStr;
|
||||
for (const auto& extension : fileExtensions) {
|
||||
if (!first) {
|
||||
extensionsStr.Append(',');
|
||||
}
|
||||
|
||||
extensionsStr.Append(extension);
|
||||
first = false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMIMEInfo> mimeInfo(do_QueryInterface(aHandlerInfo));
|
||||
MOZ_ASSERT(mimeInfo,
|
||||
"parent and child don't agree on whether this is a MIME info");
|
||||
mimeInfo->SetFileExtensions(extensionsStr);
|
||||
mimeInfo->SetFileExtensions(StringJoin(","_ns, info.extensions()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsGtkUtils.h"
|
||||
#include "nsIBidiKeyboard.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsWindow.h"
|
||||
#include "gfxPlatformGtk.h"
|
||||
|
@ -193,14 +194,11 @@ static const nsCString GetCharacterCodeNames(const char16_t* aChars,
|
|||
return "\"\""_ns;
|
||||
}
|
||||
nsCString result;
|
||||
for (uint32_t i = 0; i < aLength; ++i) {
|
||||
if (!result.IsEmpty()) {
|
||||
result.AppendLiteral(", ");
|
||||
} else {
|
||||
result.AssignLiteral("\"");
|
||||
}
|
||||
result.Append(GetCharacterCodeName(aChars[i]));
|
||||
}
|
||||
StringJoinAppend(result, ", "_ns, Span{aChars, aLength},
|
||||
[](nsACString& dest, const char16_t charValue) {
|
||||
dest.Append(GetCharacterCodeName(charValue));
|
||||
});
|
||||
result.AppendLiteral("\"");
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "nsMemory.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsQuickSort.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
@ -448,38 +449,32 @@ static const nsCString GetKeyLocationName(uint32_t aLocation) {
|
|||
}
|
||||
}
|
||||
|
||||
static const nsCString GetCharacterCodeName(const char16_t* aChars,
|
||||
static const nsCString GetCharacterCodeNames(const char16_t* aChars,
|
||||
uint32_t aLength) {
|
||||
if (!aLength) {
|
||||
return ""_ns;
|
||||
}
|
||||
nsCString result;
|
||||
for (uint32_t i = 0; i < aLength; ++i) {
|
||||
if (!result.IsEmpty()) {
|
||||
result.AppendLiteral(", ");
|
||||
} else {
|
||||
result.AssignLiteral("\"");
|
||||
}
|
||||
result.Append(GetCharacterCodeName(aChars[i]));
|
||||
}
|
||||
StringJoinAppend(result, ", "_ns, Span{aChars, aLength},
|
||||
[](nsACString& dest, const char16_t charValue) {
|
||||
dest.Append(GetCharacterCodeName(charValue));
|
||||
});
|
||||
result.AppendLiteral("\"");
|
||||
return result;
|
||||
}
|
||||
|
||||
static const nsCString GetCharacterCodeName(
|
||||
static const nsCString GetCharacterCodeNames(
|
||||
const UniCharsAndModifiers& aUniCharsAndModifiers) {
|
||||
if (aUniCharsAndModifiers.IsEmpty()) {
|
||||
return ""_ns;
|
||||
}
|
||||
nsCString result;
|
||||
for (uint32_t i = 0; i < aUniCharsAndModifiers.Length(); i++) {
|
||||
if (!result.IsEmpty()) {
|
||||
result.AppendLiteral(", ");
|
||||
} else {
|
||||
result.AssignLiteral("\"");
|
||||
}
|
||||
result.Append(GetCharacterCodeName(aUniCharsAndModifiers.CharAt(i)));
|
||||
}
|
||||
StringJoinAppend(result, ", "_ns, Span{aUniCharsAndModifiers.ToString()},
|
||||
[](nsACString& dest, const char16_t charValue) {
|
||||
dest.Append(GetCharacterCodeName(charValue));
|
||||
});
|
||||
result.AppendLiteral("\"");
|
||||
return result;
|
||||
}
|
||||
|
@ -4471,7 +4466,7 @@ void KeyboardLayout::LoadLayout(HKL aLayout) {
|
|||
(" %s (%d): DeadChar(%s, %s) (ret=%d)",
|
||||
kVirtualKeyName[virtualKey], vki,
|
||||
GetShiftStateName(shiftState).get(),
|
||||
GetCharacterCodeName(deadChar, 1).get(), ret));
|
||||
GetCharacterCodeNames(deadChar, 1).get(), ret));
|
||||
} else {
|
||||
if (ret == 1) {
|
||||
// dead-key can pair only with exactly one base character.
|
||||
|
@ -4482,7 +4477,7 @@ void KeyboardLayout::LoadLayout(HKL aLayout) {
|
|||
(" %s (%d): NormalChar(%s, %s) (ret=%d)",
|
||||
kVirtualKeyName[virtualKey], vki,
|
||||
GetShiftStateName(shiftState).get(),
|
||||
GetCharacterCodeName(uniChars, ret).get(), ret));
|
||||
GetCharacterCodeNames(uniChars, ret).get(), ret));
|
||||
}
|
||||
|
||||
// If the key inputs at least one character with AltGr modifier,
|
||||
|
@ -4494,11 +4489,11 @@ void KeyboardLayout::LoadLayout(HKL aLayout) {
|
|||
MOZ_LOG(sKeyboardLayoutLogger, LogLevel::Info,
|
||||
(" Found a key (%s) changed by AltGr: %s -> %s (%s) (ret=%d)",
|
||||
kVirtualKeyName[virtualKey],
|
||||
GetCharacterCodeName(
|
||||
GetCharacterCodeNames(
|
||||
mVirtualKeys[vki].GetNativeUniChars(
|
||||
shiftState - VirtualKey::ShiftStateIndex::eAltGr))
|
||||
.get(),
|
||||
GetCharacterCodeName(
|
||||
GetCharacterCodeNames(
|
||||
mVirtualKeys[vki].GetNativeUniChars(shiftState))
|
||||
.get(),
|
||||
GetShiftStateName(shiftState).get(), ret));
|
||||
|
@ -4805,10 +4800,10 @@ uint32_t KeyboardLayout::GetDeadKeyCombinations(
|
|||
sKeyboardLayoutLogger, LogLevel::Debug,
|
||||
(" %s -> %s (%d): DeadKeyEntry(%s, %s) (ret=%d)",
|
||||
kVirtualKeyName[aDeadKey], kVirtualKeyName[virtualKey], vki,
|
||||
GetCharacterCodeName(compositeChars, 1).get(),
|
||||
GetCharacterCodeNames(compositeChars, 1).get(),
|
||||
ret <= 0
|
||||
? "''"
|
||||
: GetCharacterCodeName(baseChars, std::min(ret, 5)).get(),
|
||||
: GetCharacterCodeNames(baseChars, std::min(ret, 5)).get(),
|
||||
ret));
|
||||
break;
|
||||
}
|
||||
|
@ -4823,7 +4818,7 @@ uint32_t KeyboardLayout::GetDeadKeyCombinations(
|
|||
kVirtualKeyName[aDeadKey], kVirtualKeyName[virtualKey], vki,
|
||||
ret <= 0
|
||||
? "''"
|
||||
: GetCharacterCodeName(compositeChars, std::min(ret, 5))
|
||||
: GetCharacterCodeNames(compositeChars, std::min(ret, 5))
|
||||
.get(),
|
||||
ret));
|
||||
break;
|
||||
|
|
|
@ -347,13 +347,14 @@ nsLocalFile::GetRelativeDescriptor(nsIFile* aFromFile, nsACString& aResult) {
|
|||
for (nodeIndex = branchIndex; nodeIndex < fromNodes.Length(); ++nodeIndex) {
|
||||
aResult.AppendLiteral("../");
|
||||
}
|
||||
for (nodeIndex = branchIndex; nodeIndex < thisNodes.Length(); ++nodeIndex) {
|
||||
NS_ConvertUTF16toUTF8 nodeStr(thisNodes[nodeIndex]);
|
||||
aResult.Append(nodeStr);
|
||||
if (nodeIndex + 1 < thisNodes.Length()) {
|
||||
aResult.Append('/');
|
||||
}
|
||||
}
|
||||
StringJoinAppend(aResult, "/"_ns, mozilla::Span{thisNodes}.From(branchIndex),
|
||||
[](nsACString& dest, const auto& thisNode) {
|
||||
// XXX(Bug 1682869) We wouldn't need to reconstruct a
|
||||
// nsDependentString here if SplitPath already returned
|
||||
// nsDependentString. In fact, it seems SplitPath might be
|
||||
// replaced by ParseString?
|
||||
AppendUTF16toUTF8(nsDependentString{thisNode}, dest);
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -452,6 +452,10 @@ void StringJoinAppend(
|
|||
nsTSubstring<CharType>& aOutput,
|
||||
const nsTLiteralString<CharType>& aSeparator, const InputRange& aInputRange,
|
||||
Func&& aFunc = mozilla::detail::kStringJoinAppendDefault) {
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wrange-loop-analysis"
|
||||
#endif
|
||||
bool first = true;
|
||||
for (const auto& item : aInputRange) {
|
||||
if (first) {
|
||||
|
@ -462,6 +466,9 @@ void StringJoinAppend(
|
|||
|
||||
aFunc(aOutput, item);
|
||||
}
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче