Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch fx_ver_t::as_str from stringstream to append/to_string #90652

Merged
merged 3 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions src/native/corehost/fxr/fx_ver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,18 @@ bool fx_ver_t::operator >=(const fx_ver_t& b) const

pal::string_t fx_ver_t::as_str() const
{
pal::stringstream_t stream;
stream << m_major << _X(".") << m_minor << _X(".") << m_patch;
pal::string_t version = pal::to_string(m_major);
elinor-fung marked this conversation as resolved.
Show resolved Hide resolved
version += _X('.');
version += pal::to_string(m_minor);
version += _X('.');
version += pal::to_string(m_patch);
if (!m_pre.empty())
{
stream << m_pre;
}
if (!m_build.empty())
{
stream << m_build;
}
return stream.str();
}
version += m_pre;

pal::string_t fx_ver_t::prerelease_glob() const
{
pal::stringstream_t stream;
stream << m_major << _X(".") << m_minor << _X(".") << m_patch << _X("-*");
return stream.str();
}
if (!m_build.empty())
version += m_build;

pal::string_t fx_ver_t::patch_glob() const
{
pal::stringstream_t stream;
stream << m_major << _X(".") << m_minor << _X(".*");
return stream.str();
return version;
}

static pal::string_t getId(const pal::string_t &ids, size_t idStart)
Expand Down
2 changes: 0 additions & 2 deletions src/native/corehost/fxr/fx_ver.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ struct fx_ver_t
bool is_empty() const { return m_major == -1; }

pal::string_t as_str() const;
pal::string_t prerelease_glob() const;
pal::string_t patch_glob() const;

bool operator ==(const fx_ver_t& b) const;
bool operator !=(const fx_ver_t& b) const;
Expand Down
16 changes: 9 additions & 7 deletions src/native/corehost/hostpolicy/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,31 @@ bool version_t::operator >=(const version_t& b) const

pal::string_t version_t::as_str() const
{
pal::stringstream_t stream;

pal::string_t version;
if (m_major >= 0)
{
stream << m_major;
version += pal::to_string(m_major);

if (m_minor >= 0)
{
stream << _X(".") << m_minor;
version += _X('.');
version += pal::to_string(m_minor);

if (m_build >= 0)
{
stream << _X(".") << m_build;
version += _X('.');
version += pal::to_string(m_build);

if (m_revision >= 0)
{
stream << _X(".") << m_revision;
version += _X('.');
version += pal::to_string(m_revision);
}
}
}
}

return stream.str();
return version;
}

/*static*/ int version_t::compare(const version_t&a, const version_t& b)
Expand Down