pre-initialize size of vectors for writing nps/notes per measure to cache file.
This commit is contained in:
@@ -447,7 +447,7 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa
|
|||||||
// The vast majority of charts don't, so there's no reason to store duplicated data.
|
// The vast majority of charts don't, so there's no reason to store duplicated data.
|
||||||
const std::vector<std::vector<float>> &allNpsPerMeasures = in.GetAllNpsPerMeasures();
|
const std::vector<std::vector<float>> &allNpsPerMeasures = in.GetAllNpsPerMeasures();
|
||||||
std::vector<RString> npsPerMeasureStrings;
|
std::vector<RString> npsPerMeasureStrings;
|
||||||
|
npsPerMeasureStrings.reserve(allNpsPerMeasures.size());
|
||||||
for(std::vector<float> npsPerMeasure : allNpsPerMeasures)
|
for(std::vector<float> npsPerMeasure : allNpsPerMeasures)
|
||||||
{
|
{
|
||||||
npsPerMeasureStrings.push_back(serialize(npsPerMeasure, ",", 3));
|
npsPerMeasureStrings.push_back(serialize(npsPerMeasure, ",", 3));
|
||||||
@@ -457,7 +457,7 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa
|
|||||||
|
|
||||||
const std::vector<std::vector<int>> &allNotesPerMeasures = in.GetAllNotesPerMeasures();
|
const std::vector<std::vector<int>> &allNotesPerMeasures = in.GetAllNotesPerMeasures();
|
||||||
std::vector<RString> notesPerMeasureStrings;
|
std::vector<RString> notesPerMeasureStrings;
|
||||||
|
notesPerMeasureStrings.reserve(allNotesPerMeasures.size());
|
||||||
for(std::vector<int> notesPerMeasure : allNotesPerMeasures)
|
for(std::vector<int> notesPerMeasure : allNotesPerMeasures)
|
||||||
{
|
{
|
||||||
notesPerMeasureStrings.push_back(serialize(notesPerMeasure, ","));
|
notesPerMeasureStrings.push_back(serialize(notesPerMeasure, ","));
|
||||||
|
|||||||
@@ -724,6 +724,7 @@ RString join( const RString &sDelimitor, std::vector<RString>::const_iterator be
|
|||||||
RString serialize(const std::vector<float> & sSource, const RString &sDelimitor, int precision)
|
RString serialize(const std::vector<float> & sSource, const RString &sDelimitor, int precision)
|
||||||
{
|
{
|
||||||
std::vector<RString> values;
|
std::vector<RString> values;
|
||||||
|
values.reserve(sSource.size());
|
||||||
RString precisionStr = ssprintf("%%.%df", precision);
|
RString precisionStr = ssprintf("%%.%df", precision);
|
||||||
for(float s : sSource)
|
for(float s : sSource)
|
||||||
{
|
{
|
||||||
@@ -735,6 +736,7 @@ RString serialize(const std::vector<float> & sSource, const RString &sDelimitor,
|
|||||||
RString serialize(const std::vector<int> & sSource, const RString &sDelimitor)
|
RString serialize(const std::vector<int> & sSource, const RString &sDelimitor)
|
||||||
{
|
{
|
||||||
std::vector<RString> values;
|
std::vector<RString> values;
|
||||||
|
values.reserve(sSource.size());
|
||||||
for(int s : sSource)
|
for(int s : sSource)
|
||||||
{
|
{
|
||||||
values.push_back(ssprintf("%d", s));
|
values.push_back(ssprintf("%d", s));
|
||||||
|
|||||||
Reference in New Issue
Block a user