mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-10 01:50:53 +09:00
Address some SString
const issues (#92156)
* SString const correctness updates * Remove const from SString::Normalize() * Remove the SString += operator * Remove unused operator[]
This commit is contained in:
parent
4d948a0e50
commit
19445f05aa
11 changed files with 48 additions and 63 deletions
|
@ -45,8 +45,8 @@ class SArray
|
|||
|
||||
COUNT_T GetAllocation() const;
|
||||
|
||||
void Preallocate(int count) const;
|
||||
void Trim() const;
|
||||
void Preallocate(int count);
|
||||
void Trim();
|
||||
|
||||
void Copy(const Iterator &to, const Iterator &from, COUNT_T size);
|
||||
void Move(const Iterator &to, const Iterator &from, COUNT_T size);
|
||||
|
|
|
@ -165,14 +165,14 @@ inline COUNT_T SArray<ELEMENT, BITWISE_COPY>::GetAllocation() const
|
|||
}
|
||||
|
||||
template <typename ELEMENT, BOOL BITWISE_COPY>
|
||||
inline void SArray<ELEMENT, BITWISE_COPY>::Preallocate(int count) const
|
||||
inline void SArray<ELEMENT, BITWISE_COPY>::Preallocate(int count)
|
||||
{
|
||||
WRAPPER_NO_CONTRACT;
|
||||
m_buffer.Preallocate(count * sizeof(ELEMENT));
|
||||
}
|
||||
|
||||
template <typename ELEMENT, BOOL BITWISE_COPY>
|
||||
inline void SArray<ELEMENT, BITWISE_COPY>::Trim() const
|
||||
inline void SArray<ELEMENT, BITWISE_COPY>::Trim()
|
||||
{
|
||||
WRAPPER_NO_CONTRACT;
|
||||
m_buffer.Trim();
|
||||
|
|
|
@ -142,11 +142,11 @@ class SBuffer
|
|||
// Preallocate some memory you expect to use. This can prevent
|
||||
// multiple reallocations. Note this does not change the visible
|
||||
// size of the buffer.
|
||||
void Preallocate(COUNT_T allocation) const;
|
||||
void Preallocate(COUNT_T allocation);
|
||||
|
||||
// Shrink memory usage of buffer to minimal amount. Note that
|
||||
// this does not change the visible size of the buffer.
|
||||
void Trim() const;
|
||||
void Trim();
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Content manipulation routines
|
||||
|
|
|
@ -382,7 +382,7 @@ inline COUNT_T SBuffer::GetAllocation() const
|
|||
RETURN m_allocation;
|
||||
}
|
||||
|
||||
inline void SBuffer::Preallocate(COUNT_T allocation) const
|
||||
inline void SBuffer::Preallocate(COUNT_T allocation)
|
||||
{
|
||||
CONTRACT_VOID
|
||||
{
|
||||
|
@ -396,12 +396,12 @@ inline void SBuffer::Preallocate(COUNT_T allocation) const
|
|||
CONTRACT_END;
|
||||
|
||||
if (allocation > m_allocation)
|
||||
const_cast<SBuffer *>(this)->ReallocateBuffer(allocation, PRESERVE);
|
||||
ReallocateBuffer(allocation, PRESERVE);
|
||||
|
||||
RETURN;
|
||||
}
|
||||
|
||||
inline void SBuffer::Trim() const
|
||||
inline void SBuffer::Trim()
|
||||
{
|
||||
CONTRACT_VOID
|
||||
{
|
||||
|
@ -412,7 +412,7 @@ inline void SBuffer::Trim() const
|
|||
CONTRACT_END;
|
||||
|
||||
if (!IsImmutable())
|
||||
const_cast<SBuffer *>(this)->ReallocateBuffer(m_size, PRESERVE);
|
||||
ReallocateBuffer(m_size, PRESERVE);
|
||||
|
||||
RETURN;
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ private:
|
|||
|
||||
// Normalizes the string representation to unicode. This can be used to
|
||||
// make basic read-only operations non-failing.
|
||||
void Normalize() const;
|
||||
void Normalize();
|
||||
|
||||
// Return the number of characters in the string (excluding the terminating NULL).
|
||||
COUNT_T GetCount() const;
|
||||
|
@ -302,10 +302,10 @@ private:
|
|||
void Replace(const Iterator &i, COUNT_T length, const SString &s);
|
||||
|
||||
// Make sure that string buffer has room to grow
|
||||
void Preallocate(COUNT_T characters) const;
|
||||
void Preallocate(COUNT_T characters);
|
||||
|
||||
// Shrink buffer size as much as possible (reallocate if necessary.)
|
||||
void Trim() const;
|
||||
void Trim();
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Iterators:
|
||||
|
@ -593,11 +593,9 @@ public:
|
|||
|
||||
operator const WCHAR * () const { WRAPPER_NO_CONTRACT; return GetUnicode(); }
|
||||
|
||||
WCHAR operator[](int index) { WRAPPER_NO_CONTRACT; return Begin()[index]; }
|
||||
WCHAR operator[](int index) const { WRAPPER_NO_CONTRACT; return Begin()[index]; }
|
||||
|
||||
SString &operator= (const SString &s) { WRAPPER_NO_CONTRACT; Set(s); return *this; }
|
||||
SString &operator+= (const SString &s) { WRAPPER_NO_CONTRACT; Append(s); return *this; }
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Check functions
|
||||
|
|
|
@ -636,7 +636,7 @@ inline const UTF8 *SString::GetUTF8() const
|
|||
}
|
||||
|
||||
// Normalize the string to unicode. This will make many operations nonfailing.
|
||||
inline void SString::Normalize() const
|
||||
inline void SString::Normalize()
|
||||
{
|
||||
SS_CONTRACT_VOID
|
||||
{
|
||||
|
@ -1097,7 +1097,7 @@ inline void SString::Delete(const Iterator &i, COUNT_T length)
|
|||
}
|
||||
|
||||
// Preallocate some space for the string buffer
|
||||
inline void SString::Preallocate(COUNT_T characters) const
|
||||
inline void SString::Preallocate(COUNT_T characters)
|
||||
{
|
||||
WRAPPER_NO_CONTRACT;
|
||||
|
||||
|
@ -1106,14 +1106,14 @@ inline void SString::Preallocate(COUNT_T characters) const
|
|||
}
|
||||
|
||||
// Trim unused space from the buffer
|
||||
inline void SString::Trim() const
|
||||
inline void SString::Trim()
|
||||
{
|
||||
WRAPPER_NO_CONTRACT;
|
||||
|
||||
if (GetRawCount() == 0)
|
||||
{
|
||||
// Share the global empty string buffer.
|
||||
const_cast<SString *>(this)->SBuffer::SetImmutable(s_EmptyBuffer, sizeof(s_EmptyBuffer));
|
||||
SBuffer::SetImmutable(s_EmptyBuffer, sizeof(s_EmptyBuffer));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -11121,7 +11121,7 @@ VOID ThrowBadFormatWorker(UINT resID, LPCWSTR imageName DEBUGARG(_In_z_ const ch
|
|||
{
|
||||
resStr.LoadResource(CCompRC::Error, BFA_BAD_IL); // "Bad IL format."
|
||||
}
|
||||
msgStr += resStr;
|
||||
msgStr.Append(resStr);
|
||||
|
||||
if ((imageName != NULL) && (imageName[0] != 0))
|
||||
{
|
||||
|
@ -11130,8 +11130,8 @@ VOID ThrowBadFormatWorker(UINT resID, LPCWSTR imageName DEBUGARG(_In_z_ const ch
|
|||
{
|
||||
SString suffixMsgStr;
|
||||
suffixMsgStr.FormatMessage(FORMAT_MESSAGE_FROM_STRING, (LPCWSTR)suffixResStr, 0, 0, SString{ SString::Literal, imageName });
|
||||
msgStr.AppendASCII(" ");
|
||||
msgStr += suffixMsgStr;
|
||||
msgStr.Append(W(" "));
|
||||
msgStr.Append(suffixMsgStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ NativeImage *NativeImage::Open(
|
|||
SString compositeImageFileName(SString::Utf8, nativeImageFileName);
|
||||
SString fullPath;
|
||||
fullPath.Set(path, path.Begin(), (COUNT_T)pathDirLength);
|
||||
fullPath += compositeImageFileName;
|
||||
fullPath.Append(compositeImageFileName);
|
||||
LPWSTR searchPathsConfig;
|
||||
IfFailThrow(CLRConfig::GetConfigValue(CLRConfig::INTERNAL_NativeImageSearchPaths, &searchPathsConfig));
|
||||
|
||||
|
@ -194,7 +194,7 @@ NativeImage *NativeImage::Open(
|
|||
}
|
||||
|
||||
fullPath.Append(DIRECTORY_SEPARATOR_CHAR_W);
|
||||
fullPath += compositeImageFileName;
|
||||
fullPath.Append(compositeImageFileName);
|
||||
|
||||
EX_TRY
|
||||
{
|
||||
|
|
|
@ -144,8 +144,8 @@ namespace
|
|||
SString::Iterator i = m_message.Begin();
|
||||
if (!m_message.Find(i, new_message))
|
||||
{
|
||||
m_message += new_message;
|
||||
m_message += SString(SString::Utf8, "\n");
|
||||
m_message.Append(new_message);
|
||||
m_message.AppendUTF8("\n");
|
||||
}
|
||||
#else
|
||||
m_message = SString(SString::Utf8, message);
|
||||
|
|
|
@ -186,7 +186,7 @@ CHECK PEImage::CheckCanonicalFullPath(const SString &path)
|
|||
{
|
||||
// Drive path
|
||||
i++;
|
||||
SString sDrivePath(SString::Literal, ":\\");
|
||||
SString sDrivePath(SString::Literal, W(":\\"));
|
||||
CCHECK(path.Skip(i, sDrivePath));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -801,15 +801,14 @@ void TypeString::AppendType(TypeNameBuilder& tnb, TypeHandle ty, Instantiation t
|
|||
StackSString ss;
|
||||
AppendType(ss, retAndArgTypes[0], format);
|
||||
|
||||
SString ssOpening(SString::Literal, "(");
|
||||
ss += ssOpening;
|
||||
|
||||
ss.Append(W("("));
|
||||
|
||||
SString ssComma(SString::Literal, ", ");
|
||||
DWORD cArgs = fnPtr->GetNumArgs();
|
||||
for (DWORD i = 1; i <= cArgs; i++)
|
||||
{
|
||||
if (i != 1)
|
||||
ss += ssComma;
|
||||
ss.Append(ssComma);
|
||||
|
||||
AppendType(ss, retAndArgTypes[i], format);
|
||||
}
|
||||
|
@ -817,20 +816,18 @@ void TypeString::AppendType(TypeNameBuilder& tnb, TypeHandle ty, Instantiation t
|
|||
if ((fnPtr->GetCallConv() & IMAGE_CEE_CS_CALLCONV_MASK) == IMAGE_CEE_CS_CALLCONV_VARARG)
|
||||
{
|
||||
if (cArgs)
|
||||
ss += ssComma;
|
||||
ss.Append(ssComma);
|
||||
|
||||
SString ssEllipsis(SString::Literal, "...");
|
||||
ss += ssEllipsis;
|
||||
}
|
||||
ss.Append(W("..."));
|
||||
}
|
||||
|
||||
ss.Append(W(")"));
|
||||
|
||||
SString ssClosing(SString::Literal, ")");
|
||||
ss += ssClosing;
|
||||
|
||||
tnb.AddNameNoEscaping(ss);
|
||||
}
|
||||
else
|
||||
{
|
||||
tnb.AddNameNoEscaping(W(""));
|
||||
{
|
||||
tnb.AddNameNoEscaping(W(""));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -941,13 +938,11 @@ void TypeString::AppendMethodImpl(SString& ss, MethodDesc *pMD, Instantiation ty
|
|||
{
|
||||
if (pMD->IsLCGMethod())
|
||||
{
|
||||
SString sss(SString::Literal, "DynamicClass");
|
||||
ss += sss;
|
||||
ss.AppendUTF8("DynamicClass");
|
||||
}
|
||||
else if (pMD->IsILStub())
|
||||
{
|
||||
SString sss(SString::Literal, ILStubResolver::GetStubClassName(pMD));
|
||||
ss += sss;
|
||||
ss.AppendUTF8(ILStubResolver::GetStubClassName(pMD));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -956,10 +951,8 @@ void TypeString::AppendMethodImpl(SString& ss, MethodDesc *pMD, Instantiation ty
|
|||
AppendType(ss, th, typeInstantiation, format);
|
||||
}
|
||||
|
||||
SString sss1(SString::Literal, NAMESPACE_SEPARATOR_STR);
|
||||
ss += sss1;
|
||||
SString sss2(SString::Utf8, pMD->GetName());
|
||||
ss += sss2;
|
||||
ss.AppendUTF8(NAMESPACE_SEPARATOR_STR);
|
||||
ss.AppendUTF8(pMD->GetName());
|
||||
|
||||
if (pMD->HasMethodInstantiation() && !pMD->IsGenericMethodDefinition())
|
||||
{
|
||||
|
@ -972,40 +965,34 @@ void TypeString::AppendMethodImpl(SString& ss, MethodDesc *pMD, Instantiation ty
|
|||
|
||||
SigFormat sigFormatter(pMD, th);
|
||||
const char* sigStr = sigFormatter.GetCStringParmsOnly();
|
||||
SString sss(SString::Utf8, sigStr);
|
||||
ss += sss;
|
||||
ss.AppendUTF8(sigStr);
|
||||
}
|
||||
|
||||
if (format & FormatStubInfo) {
|
||||
if (format & FormatStubInfo)
|
||||
{
|
||||
if (pMD->IsInstantiatingStub())
|
||||
{
|
||||
SString sss(SString::Literal, "{inst-stub}");
|
||||
ss += sss;
|
||||
ss.AppendUTF8("{inst-stub}");
|
||||
}
|
||||
if (pMD->IsUnboxingStub())
|
||||
{
|
||||
SString sss(SString::Literal, "{unbox-stub}");
|
||||
ss += sss;
|
||||
ss.AppendUTF8("{unbox-stub}");
|
||||
}
|
||||
if (pMD->IsSharedByGenericMethodInstantiations())
|
||||
{
|
||||
SString sss(SString::Literal, "{method-shared}");
|
||||
ss += sss;
|
||||
ss.AppendUTF8("{method-shared}");
|
||||
}
|
||||
else if (pMD->IsSharedByGenericInstantiations())
|
||||
{
|
||||
SString sss(SString::Literal, "{shared}");
|
||||
ss += sss;
|
||||
ss.AppendUTF8("{shared}");
|
||||
}
|
||||
if (pMD->RequiresInstMethodTableArg())
|
||||
{
|
||||
SString sss(SString::Literal, "{requires-mt-arg}");
|
||||
ss += sss;
|
||||
ss.AppendUTF8("{requires-mt-arg}");
|
||||
}
|
||||
if (pMD->RequiresInstMethodDescArg())
|
||||
{
|
||||
SString sss(SString::Literal, "{requires-mdesc-arg}");
|
||||
ss += sss;
|
||||
ss.AppendUTF8("{requires-mdesc-arg}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue