summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonetienne <leonetienne@hotmail.de>2022-02-10 09:20:02 +0100
committerLeonetienne <leonetienne@hotmail.de>2022-02-10 09:20:02 +0100
commit9d33428557e267e40bc1032560caa28f767eb8d9 (patch)
tree4a51873cc41819280e4bed0a67dcc8738e449bf0
parent4a2df723590bd70f855d6d6f0aa4e15584205516 (diff)
Wemuvd winyebuffewing for piping to work fwawwesswy witw otwer pwogwams taking time to pwoduce output
-rw-r--r--main.cpp20
1 files changed, 2 insertions, 18 deletions
diff --git a/main.cpp b/main.cpp
index 7c3fe9b..1d5cd14 100644
--- a/main.cpp
+++ b/main.cpp
@@ -295,7 +295,7 @@ std::string MakeUwu(std::string boringString) {
// Replace random punctuation with uwwwwu cute symbols
// About evewy fifteenth symbol
std::stringstream ss;
- std::mt19937 rng(69);
+ std::mt19937 rng(std::hash<std::string>()(boringString)); // Seed rng based on string
for (const char c : boringString)
{
if ((c == '.') && (rng() % 15 == 0))
@@ -349,26 +349,10 @@ int main(int argc, char** argv) {
// Else, be prepared to get __piped__
else
{
- // We're better off processing all in one go, as to not having to re-seed the PRNG for every single line...
- // To still support BIG files / endless streams, we'll flush our buffer after every 10th line
std::string buf;
- std::stringstream ss;
- std::size_t lineCounter = 0;
while (std::getline(std::cin, buf))
- {
- ss << buf << std::endl;
- lineCounter++;
-
- if (lineCounter >= 10)
- {
- lineCounter = 0;
- std::cout << MakeUwu(ss.str()) << std::endl;
- ss.str("");
- }
- }
+ std::cout << MakeUwu(buf) << std::endl;
- // Flush one last time
- std::cout << MakeUwu(ss.str()) << std::endl;
}
return 0;