aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-28 23:46:45 +0000
committerDavid Robillard <d@drobilla.net>2010-12-28 23:46:45 +0000
commit703f1840af79ca4480c664190cdcf7e6fbd7b90e (patch)
treed4d5102914e361ea184867c23ad6f5ecb0149fe8 /src
parent33eb9bb5097e3e9c16529fca87f5f12300cc21d7 (diff)
downloadresp-703f1840af79ca4480c664190cdcf7e6fbd7b90e.tar.gz
resp-703f1840af79ca4480c664190cdcf7e6fbd7b90e.tar.bz2
resp-703f1840af79ca4480c664190cdcf7e6fbd7b90e.zip
Avoid string copy (store const char* for command line filenames instead of std::string).
git-svn-id: http://svn.drobilla.net/resp/resp@368 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src')
-rw-r--r--src/resp.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/resp.cpp b/src/resp.cpp
index b264850..66847fd 100644
--- a/src/resp.cpp
+++ b/src/resp.cpp
@@ -37,7 +37,7 @@ bool
is_form(const AST* ast, const std::string& form)
{
const ATuple* call = ast->to_tuple();
- if (!call)
+ if (!call || call->empty())
return false;
const ASymbol* const sym = call->fst()->to_symbol();
@@ -89,7 +89,8 @@ main(int argc, char** argv)
{
// Read command line arguments
map<string,string> args;
- list<string> files;
+ typedef list<const char*> Files;
+ Files files;
for (int i = 1; i < argc; ++i) {
if (!strncmp(argv[i], "-h", 3)) {
return print_usage(argv[0], false);
@@ -148,8 +149,8 @@ main(int argc, char** argv)
fs.open(output.c_str());
ostream& os = (output == "") ? std::cout : fs;
- for (list<string>::iterator f = files.begin(); f != files.end(); ++f) {
- ifstream is(f->c_str());
+ for (Files::iterator f = files.begin(); f != files.end(); ++f) {
+ ifstream is(*f);
try {
while (is.good() && !is.eof()) {
Cursor loc(*f);
@@ -183,14 +184,14 @@ main(int argc, char** argv)
ret = repl(*cenv);
} else { // Evalute (or just type check if -T, or just compile if -S all files
- for (list<string>::iterator f = files.begin(); f != files.end(); ++f) {
- const string& filename = *f;
+ for (Files::iterator f = files.begin(); f != files.end(); ++f) {
+ const string filename = *f;
if (!batch)
output = filename + ".out";
- ifstream is(f->c_str());
+ ifstream is(*f);
if (is.good()) {
- Cursor cursor(*f);
+ Cursor cursor(filename);
ret = ret | eval(*cenv, cursor, is, !batch);
} else {
cerr << argv[0] << ": " << *f << ": " << strerror(errno) << endl;