diff --git a/src/GraphControl/Control/Grapher.cpp b/src/GraphControl/Control/Grapher.cpp index f6953d9..0546d7e 100644 --- a/src/GraphControl/Control/Grapher.cpp +++ b/src/GraphControl/Control/Grapher.cpp @@ -263,8 +263,7 @@ namespace GraphControl if (!validEqs.empty()) { - wstringstream ss{}; - ss << s_getGraphOpeningTags; + request = s_getGraphOpeningTags; int numValidEquations = 0; for (Equation ^ eq : validEqs) @@ -276,15 +275,13 @@ namespace GraphControl if (numValidEquations++ > 0) { - ss << L","; + request += L","; } - ss << eq->GetRequest()->Data(); + request += eq->GetRequest()->Data(); } - ss << s_getGraphClosingTags; - - request = ss.str(); + request += s_getGraphClosingTags; } if (graphExpression = m_solver->ParseInput(request)) @@ -374,14 +371,11 @@ namespace GraphControl { shared_ptr graph = m_solver->CreateGrapher(); - wstringstream ss{}; - ss << s_getGraphOpeningTags; - ss << equation->GetRequest()->Data(); - ss << s_getGraphClosingTags; + wstring request = s_getGraphOpeningTags; + request += equation->GetRequest()->Data(); + request += s_getGraphClosingTags; - wstring request = ss.str(); - unique_ptr graphExpression; - if (graphExpression = m_solver->ParseInput(request)) + if (unique_ptr graphExpression = m_solver->ParseInput(request)) { if (graph->TryInitialize(graphExpression.get())) { diff --git a/src/GraphControl/Models/Equation.cpp b/src/GraphControl/Models/Equation.cpp index 3ca9313..52cdb7c 100644 --- a/src/GraphControl/Models/Equation.cpp +++ b/src/GraphControl/Models/Equation.cpp @@ -24,26 +24,27 @@ namespace GraphControl String ^ Equation::GetRequest() { - wstringstream ss; - wstring expr{ Expression->Data() }; + wstring request; + wstring_view expr{ Expression->Data() }; // Check for unicode characters of less than, less than or equal to, greater than and greater than or equal to. - if (expr.find(L">><") != wstring::npos || expr.find(L"><<") != wstring::npos || expr.find(L">≥<") != wstring::npos - || expr.find(L">≤<") != wstring::npos) + if (expr.find(L">><") != wstring_view::npos || expr.find(L"><<") != wstring_view::npos || expr.find(L">≥<") != wstring_view::npos + || expr.find(L">≤<") != wstring_view::npos) { - ss << L"plotIneq2D"s; + request = L"plotIneq2D"; } - else if (expr.find(L">=<") != wstring::npos) + else if (expr.find(L">=<") != wstring_view::npos) { - ss << L"plotEq2d"; + request = L"plotEq2d"; } else { - ss << L"plot2d"; + request = L"plot2d"; } - ss << GetExpression() << L""; + request += GetExpression(); + request += L""; - return ref new String(ss.str().c_str()); + return ref new String(request.c_str()); } wstring Equation::GetExpression() @@ -51,7 +52,7 @@ namespace GraphControl wstring mathML = Expression->Data(); size_t mathPrefix = 0; - while ((mathPrefix = mathML.find(s_mathPrefix, mathPrefix)) != std::string::npos) + while ((mathPrefix = mathML.find(s_mathPrefix, mathPrefix)) != wstring::npos) { mathML.replace(mathPrefix, s_mathPrefix.length(), L""); mathPrefix += s_mathPrefix.length();