Skip to content

Commit

Permalink
dont actually keep spitting out a billion keys just have the code in …
Browse files Browse the repository at this point in the history
…the commits
  • Loading branch information
MinaciousGrace committed Jun 1, 2017
1 parent 1d79bd1 commit dc3cbf9
Showing 1 changed file with 24 additions and 29 deletions.
53 changes: 24 additions & 29 deletions src/Steps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,42 +392,37 @@ void Steps::CalcEtternaMetadata() {
RString Steps::GenerateChartKey(NoteData& nd, TimingData *td) {
RString o = "X"; // I was thinking of using "C" to indicate chart.. however.. X is cooler... - Mina
vector<int>& nerv = nd.GetNonEmptyRowVector();

for (int i = 0; i < 8; ++i) {
unsigned int numThreads = max(std::thread::hardware_concurrency(), 1u) - i;
std::vector<RString> keyParts;
keyParts.reserve(numThreads);

size_t segmentSize = nerv.size() / numThreads;
std::vector<std::thread> threads;
threads.reserve(numThreads);
unsigned int numThreads = max(std::thread::hardware_concurrency(), 1u);
std::vector<RString> keyParts;
keyParts.reserve(numThreads);

for (unsigned int curThread = 0; curThread < numThreads; curThread++)
{
keyParts.push_back("");
size_t start = segmentSize * curThread;
size_t end = start + segmentSize;
if (curThread + 1 == numThreads)
end = nerv.size();
size_t segmentSize = nerv.size() / numThreads;
std::vector<std::thread> threads;
threads.reserve(numThreads);

threads.push_back(std::thread(&Steps::FillStringWithBPMs, this, start, end, std::ref(nerv), std::ref(nd), td, std::ref(keyParts[curThread])));
}
for (unsigned int curThread = 0; curThread < numThreads; curThread++)
{
keyParts.push_back("");
size_t start = segmentSize * curThread;
size_t end = start + segmentSize;
if (curThread + 1 == numThreads)
end = nerv.size();

for (auto& t : threads)
{
if (t.joinable())
t.join();
}
threads.push_back(std::thread(&Steps::FillStringWithBPMs, this, start, end, std::ref(nerv), std::ref(nd), td, std::ref(keyParts[curThread])));
}

// handle empty charts if they get to here -mina
if (*keyParts.data() == "")
return "";
for (auto& t : threads)
{
if (t.joinable())
t.join();
}

LOG->Trace("Threads Used: %i, *keyparts.data() = %s", numThreads, *keyParts.data());
// handle empty charts if they get to here -mina
if (*keyParts.data() == "")
return "";

if(i == 0)
o.append(BinaryToHex(CryptManager::GetSHA1ForString(*keyParts.data())));
}
o.append(BinaryToHex(CryptManager::GetSHA1ForString(*keyParts.data())));

return o;
}
Expand Down

0 comments on commit dc3cbf9

Please sign in to comment.