Skip to content

Commit 8e6ddf8

Browse files
committed
removed unnecessary usage of std::istringstream
1 parent 702f46d commit 8e6ddf8

File tree

6 files changed

+8
-17
lines changed

6 files changed

+8
-17
lines changed

lib/importproject.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,7 @@ namespace {
567567
// TODO: improve evaluation
568568
const Settings s;
569569
TokenList tokenlist(&s);
570-
std::istringstream istr(c);
571-
tokenlist.createTokens(istr, Standards::Language::C); // TODO: check result
570+
tokenlist.createTokens(c.data(), c.size(), Standards::Language::C); // TODO: check result
572571
// TODO: put in a helper
573572
// generate links
574573
{

test/helpers.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ class SimpleTokenizer : public Tokenizer {
7878
bool cpp = true,
7979
const std::string &configuration = emptyString)
8080
{
81-
std::istringstream istr(code);
82-
if (!list.createTokens(istr, cpp ? "test.cpp" : "test.c"))
81+
if (!list.createTokens(code, size-1, cpp ? "test.cpp" : "test.c"))
8382
return false;
8483

8584
return simplifyTokens1(configuration);
@@ -90,8 +89,7 @@ class SimpleTokenizer : public Tokenizer {
9089
bool cpp = true,
9190
const std::string &configuration = emptyString)
9291
{
93-
std::istringstream istr(code);
94-
if (!list.createTokens(istr, cpp ? "test.cpp" : "test.c"))
92+
if (!list.createTokens(code.c_str(), code.size(), cpp ? "test.cpp" : "test.c"))
9593
return false;
9694

9795
return simplifyTokens1(configuration);

test/testclass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#include <cstddef>
2929
#include <list>
30-
#include <sstream>
3130
#include <string>
3231
#include <vector>
3332

@@ -8915,9 +8914,8 @@ class TestClass : public TestFixture {
89158914
std::list<Check::FileInfo*> fileInfo;
89168915
for (const std::string& c: code) {
89178916
Tokenizer tokenizer(settingsDefault, *this);
8918-
std::istringstream istr(c);
89198917
const std::string filename = std::to_string(fileInfo.size()) + ".cpp";
8920-
ASSERT(tokenizer.list.createTokens(istr, filename));
8918+
ASSERT(tokenizer.list.createTokens(c.data(), c.size(), filename));
89218919
ASSERT(tokenizer.simplifyTokens1(""));
89228920
fileInfo.push_back(check.getFileInfo(tokenizer, settingsDefault));
89238921
}

test/testtokenize.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,7 @@ class TestTokenizer : public TestFixture {
832832
{
833833
Tokenizer tokenizer(settings1, *this);
834834
const char code[] = "void foo(int i) { reinterpret_cast<char>(i) };";
835-
std::istringstream istr(code);
836-
ASSERT(tokenizer.list.createTokens(istr, "test.h"));
835+
ASSERT(tokenizer.list.createTokens(code, "test.h"));
837836
ASSERT_THROW_INTERNAL(tokenizer.simplifyTokens1(""), SYNTAX);
838837
}
839838
}

test/testtokenlist.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,10 @@ class TestTokenList : public TestFixture {
164164
}
165165

166166
void ast1() const {
167-
const std::string s = "('Release|x64' == 'Release|x64');";
167+
const char code[] = "('Release|x64' == 'Release|x64');";
168168

169169
TokenList tokenlist(&settings);
170-
std::istringstream istr(s);
171-
tokenlist.createTokens(istr, Standards::Language::C);
170+
tokenlist.createTokens(code, Standards::Language::C);
172171
// TODO: put this logic in TokenList
173172
// generate links
174173
{

test/testunusedfunctions.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "tokenlist.h"
2727

2828
#include <cstddef>
29-
#include <sstream>
3029
#include <string>
3130

3231
class TestUnusedFunctions : public TestFixture {
@@ -572,8 +571,7 @@ class TestUnusedFunctions : public TestFixture {
572571
const std::string fname = "test" + std::to_string(i) + ".cpp";
573572

574573
Tokenizer tokenizer(settings, *this);
575-
std::istringstream istr(code);
576-
ASSERT(tokenizer.list.createTokens(istr, fname));
574+
ASSERT(tokenizer.list.createTokens(code, fname));
577575
ASSERT(tokenizer.simplifyTokens1(""));
578576

579577
c.parseTokens(tokenizer, settings);

0 commit comments

Comments
 (0)