Skip to content

Commit e64cdbb

Browse files
[release/8.0] Switch fx_ver_t::as_str from stringstream to append/to_string (#90760)
* Switch fx_ver_t::as_str from stringstream to append/to_string * Switch version_t::as_str * Remove unnecessary include --------- Co-authored-by: Elinor Fung <elfung@microsoft.com>
1 parent a2953d7 commit e64cdbb

File tree

5 files changed

+18
-33
lines changed

5 files changed

+18
-33
lines changed

src/native/corehost/fxr/fx_ver.cpp

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,18 @@ bool fx_ver_t::operator >=(const fx_ver_t& b) const
7070

7171
pal::string_t fx_ver_t::as_str() const
7272
{
73-
pal::stringstream_t stream;
74-
stream << m_major << _X(".") << m_minor << _X(".") << m_patch;
73+
pal::string_t version = pal::to_string(m_major);
74+
version += _X('.');
75+
version += pal::to_string(m_minor);
76+
version += _X('.');
77+
version += pal::to_string(m_patch);
7578
if (!m_pre.empty())
76-
{
77-
stream << m_pre;
78-
}
79-
if (!m_build.empty())
80-
{
81-
stream << m_build;
82-
}
83-
return stream.str();
84-
}
79+
version += m_pre;
8580

86-
pal::string_t fx_ver_t::prerelease_glob() const
87-
{
88-
pal::stringstream_t stream;
89-
stream << m_major << _X(".") << m_minor << _X(".") << m_patch << _X("-*");
90-
return stream.str();
91-
}
81+
if (!m_build.empty())
82+
version += m_build;
9283

93-
pal::string_t fx_ver_t::patch_glob() const
94-
{
95-
pal::stringstream_t stream;
96-
stream << m_major << _X(".") << m_minor << _X(".*");
97-
return stream.str();
84+
return version;
9885
}
9986

10087
static pal::string_t getId(const pal::string_t &ids, size_t idStart)

src/native/corehost/fxr/fx_ver.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ struct fx_ver_t
2626
bool is_empty() const { return m_major == -1; }
2727

2828
pal::string_t as_str() const;
29-
pal::string_t prerelease_glob() const;
30-
pal::string_t patch_glob() const;
3129

3230
bool operator ==(const fx_ver_t& b) const;
3331
bool operator !=(const fx_ver_t& b) const;

src/native/corehost/hostmisc/pal.unix.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <fcntl.h>
1717
#include <fnmatch.h>
1818
#include <ctime>
19-
#include <locale>
2019
#include <pwd.h>
2120
#include "config.h"
2221
#include <minipal/getexepath.h>

src/native/corehost/hostmisc/pal.windows.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "longfile.h"
88

99
#include <cassert>
10-
#include <locale>
1110
#include <ShlObj.h>
1211
#include <ctime>
1312

src/native/corehost/hostpolicy/version.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,31 @@ bool version_t::operator >=(const version_t& b) const
5151

5252
pal::string_t version_t::as_str() const
5353
{
54-
pal::stringstream_t stream;
55-
54+
pal::string_t version;
5655
if (m_major >= 0)
5756
{
58-
stream << m_major;
57+
version += pal::to_string(m_major);
5958

6059
if (m_minor >= 0)
6160
{
62-
stream << _X(".") << m_minor;
61+
version += _X('.');
62+
version += pal::to_string(m_minor);
6363

6464
if (m_build >= 0)
6565
{
66-
stream << _X(".") << m_build;
66+
version += _X('.');
67+
version += pal::to_string(m_build);
6768

6869
if (m_revision >= 0)
6970
{
70-
stream << _X(".") << m_revision;
71+
version += _X('.');
72+
version += pal::to_string(m_revision);
7173
}
7274
}
7375
}
7476
}
7577

76-
return stream.str();
78+
return version;
7779
}
7880

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

0 commit comments

Comments
 (0)