summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-04 17:21:44 +0000
committerDavid Robillard <d@drobilla.net>2010-02-04 17:21:44 +0000
commit7c19aa2a97c1e19b27b66c58a84c46489101950e (patch)
tree72b2fac98b6f69bc16770194900c0e0bec86311b
parentb8ef9bff8a46a682f68585aad7587bf081e8b7f8 (diff)
downloadingen-7c19aa2a97c1e19b27b66c58a84c46489101950e.tar.gz
ingen-7c19aa2a97c1e19b27b66c58a84c46489101950e.tar.bz2
ingen-7c19aa2a97c1e19b27b66c58a84c46489101950e.zip
Use std::string::empty where possible (faster, and less prone to C string errors).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2420 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/client/DeprecatedLoader.cpp20
-rw-r--r--src/client/HTTPClientReceiver.cpp6
-rw-r--r--src/client/PluginModel.cpp2
-rw-r--r--src/engine/HTTPEngineReceiver.cpp2
-rw-r--r--src/engine/JackDriver.cpp6
-rw-r--r--src/engine/LV2Plugin.cpp2
-rw-r--r--src/engine/NodeBase.hpp2
-rw-r--r--src/engine/NodeFactory.cpp6
-rw-r--r--src/engine/events/CreateNode.cpp2
-rw-r--r--src/engine/events/CreatePort.cpp1
-rw-r--r--src/gui/GladeFactory.cpp4
-rw-r--r--src/gui/LoadPluginWindow.cpp4
-rw-r--r--src/gui/NodeModule.cpp2
-rw-r--r--src/gui/PatchCanvas.cpp4
-rw-r--r--src/gui/PatchWindow.cpp2
-rw-r--r--src/gui/RenameWindow.cpp4
-rw-r--r--src/scripts/python/ingen.py2
-rw-r--r--src/serialisation/Parser.cpp14
-rw-r--r--src/shared/ClashAvoider.cpp2
19 files changed, 43 insertions, 44 deletions
diff --git a/src/client/DeprecatedLoader.cpp b/src/client/DeprecatedLoader.cpp
index 8d774e17..5fd5720d 100644
--- a/src/client/DeprecatedLoader.cpp
+++ b/src/client/DeprecatedLoader.cpp
@@ -85,7 +85,7 @@ public:
if (port_name == "note_number") // FIXME: filthy kludge
port_name = "note";
- if (node_name != "")
+ if (!node_name.empty())
_controls.push_back(ControlModel(_base_path + node_name +"/"+ port_name, value));
else
_controls.push_back(ControlModel(_base_path + port_name, value));
@@ -151,13 +151,13 @@ DeprecatedLoader::translate_load_path(const string& path)
void
DeprecatedLoader::add_variable(GraphObject::Properties& data, string old_key, string value)
{
- string key = "";
+ string key;
if (old_key == "module-x")
key = "ingenui:canvas-x";
else if (old_key == "module-y")
key = "ingenui:canvas-y";
- if (key != "") {
+ if (!key.empty()) {
// FIXME: should this overwrite existing values?
if (data.find(key) == data.end()) {
// Hack to make module-x and module-y set as floats
@@ -448,7 +448,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr
cur = cur->next;
}
- if (path == "") {
+ if (path.empty()) {
LOG(error) << "Malformed patch file (node tag has empty children)" << endl;
LOG(error) << "Node ignored." << endl;
return false;
@@ -457,7 +457,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr
const LV2URIMap& uris = Shared::LV2URIMap::instance();
// Compatibility hacks for old patches that represent patch ports as nodes
- if (plugin_uri == "") {
+ if (plugin_uri.empty()) {
bool is_port = false;
Resource::Properties props;
@@ -529,7 +529,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr
plugin_uri = NS_INTERNALS "Trigger";
}
- if (plugin_uri == "")
+ if (plugin_uri.empty())
plugin_uri = "om:" + plugin_type + ":" + library_name + ":" + plugin_label;
Resource::Properties props;
@@ -631,7 +631,7 @@ DeprecatedLoader::load_connection(const Path& parent, xmlDocPtr doc, const xmlNo
cur = cur->next;
}
- if (source_node == "" || source_port == "" || dest_node == "" || dest_port == "") {
+ if (source_node.empty() || source_port.empty() || dest_node.empty() || dest_port.empty()) {
LOG(error) << "Malformed patch file (connection tag has empty children)" << endl;
LOG(error) << "Connection ignored." << endl;
return false;
@@ -691,11 +691,11 @@ DeprecatedLoader::load_preset(const Path& parent, xmlDocPtr doc, const xmlNodePt
}
// Compatibility fixes for old patch files
- if (node_name != "")
+ if (!node_name.empty())
node_name = nameify_if_invalid(node_name);
port_name = nameify_if_invalid(port_name);
- if (port_name == "") {
+ if (port_name.empty()) {
string msg = "Unable to parse control in patch file ( node = ";
msg.append(node_name).append(", port = ").append(port_name).append(")");
LOG(error) << msg << endl;
@@ -713,7 +713,7 @@ DeprecatedLoader::load_preset(const Path& parent, xmlDocPtr doc, const xmlNodePt
key = NULL;
cur = cur->next;
}
- if (pm->name() == "") {
+ if (pm->name().empty()) {
LOG(error) << "Preset in patch file has no name." << endl;
//m_client_hooks->error("Preset in patch file has no name.");
pm->name("Unnamed");
diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp
index 1706b77c..ffa142a5 100644
--- a/src/client/HTTPClientReceiver.cpp
+++ b/src/client/HTTPClientReceiver.cpp
@@ -142,15 +142,15 @@ HTTPClientReceiver::Listener::_run()
char in = '\0';
char last = '\0';
char llast = '\0';
- string recv = "";
+ string recv;
while (true) {
while (read(_sock, &in, 1) > 0 ) {
recv += in;
if (in == '\n' && last == '\n' && llast == '\n') {
- if (recv != "") {
+ if (!recv.empty()) {
_receiver->update(recv);
- recv = "";
+ recv.clear();
last = '\0';
llast = '\0';
}
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index 43571f08..b50513ce 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -223,7 +223,7 @@ PluginModel::ui(Ingen::Shared::World* world, SharedPtr<NodeModel> node) const
const string&
PluginModel::icon_path() const
{
- if (_icon_path == "" && _type == LV2) {
+ if (_icon_path.empty() && _type == LV2) {
Glib::Mutex::Lock lock(_rdf_world->mutex());
_icon_path = get_lv2_icon_path(_slv2_plugin);
}
diff --git a/src/engine/HTTPEngineReceiver.cpp b/src/engine/HTTPEngineReceiver.cpp
index 025243eb..dbda1ddd 100644
--- a/src/engine/HTTPEngineReceiver.cpp
+++ b/src/engine/HTTPEngineReceiver.cpp
@@ -117,7 +117,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const
// Special GET paths
if (msg->method == SOUP_METHOD_GET) {
- if (path == Path::root.str() || path == "") {
+ if (path == Path::root.str() || path.empty()) {
const string r = string("@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n")
.append("\n<> rdfs:seeAlso <plugins> ;")
.append("\n rdfs:seeAlso <stream> ;")
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp
index fc2e5e59..e903586e 100644
--- a/src/engine/JackDriver.cpp
+++ b/src/engine/JackDriver.cpp
@@ -219,13 +219,13 @@ JackDriver::supports(Shared::PortType port_type, Shared::EventType event_type)
bool
JackDriver::attach(const std::string& server_name,
- const std::string& client_name,
- void* jack_client)
+ const std::string& client_name,
+ void* jack_client)
{
assert(!_client);
if (!jack_client) {
// Try supplied server name
- if (server_name != "") {
+ if (!server_name.empty()) {
_client = jack_client_open(client_name.c_str(),
JackServerName, NULL, server_name.c_str());
if (_client)
diff --git a/src/engine/LV2Plugin.cpp b/src/engine/LV2Plugin.cpp
index 95cb93f0..d522307a 100644
--- a/src/engine/LV2Plugin.cpp
+++ b/src/engine/LV2Plugin.cpp
@@ -97,7 +97,7 @@ const std::string&
LV2Plugin::library_path() const
{
static const std::string empty_string;
- if (_library_path == "") {
+ if (_library_path.empty()) {
SLV2Value v = slv2_plugin_get_library_uri(_slv2_plugin);
if (v) {
_library_path = slv2_uri_to_path(slv2_value_as_uri(v));
diff --git a/src/engine/NodeBase.hpp b/src/engine/NodeBase.hpp
index 950a79a3..637c8560 100644
--- a/src/engine/NodeBase.hpp
+++ b/src/engine/NodeBase.hpp
@@ -41,8 +41,6 @@ namespace Shared { class ClientInterface; }
/** Common implementation stuff for Node.
*
- * Pretty much just attributes and getters/setters are here.
- *
* \ingroup engine
*/
class NodeBase : public NodeImpl
diff --git a/src/engine/NodeFactory.cpp b/src/engine/NodeFactory.cpp
index de321077..335feb26 100644
--- a/src/engine/NodeFactory.cpp
+++ b/src/engine/NodeFactory.cpp
@@ -86,7 +86,7 @@ NodeFactory::plugin(const Raul::URI& uri)
PluginImpl*
NodeFactory::plugin(const string& type, const string& lib, const string& label)
{
- if (type != "LADSPA" || lib == "" || label == "")
+ if (type != "LADSPA" || lib.empty() || label.empty())
return NULL;
#ifdef HAVE_LADSPA_H
@@ -206,12 +206,12 @@ NodeFactory::load_ladspa_plugins()
}
// Yep, this should use an sstream alright..
- while (ladspa_path != "") {
+ while (!ladspa_path.empty()) {
const string dir = ladspa_path.substr(0, ladspa_path.find(':'));
if (ladspa_path.find(':') != string::npos)
ladspa_path = ladspa_path.substr(ladspa_path.find(':')+1);
else
- ladspa_path = "";
+ ladspa_path.clear();
DIR* pdir = opendir(dir.c_str());
if (pdir == NULL)
diff --git a/src/engine/events/CreateNode.cpp b/src/engine/events/CreateNode.cpp
index 426044ee..4f5b4877 100644
--- a/src/engine/events/CreateNode.cpp
+++ b/src/engine/events/CreateNode.cpp
@@ -83,7 +83,7 @@ CreateNode::pre_process()
_patch = _engine.engine_store()->find_patch(_path.parent());
- _plugin = (_plugin_label == "")
+ _plugin = (_plugin_label.empty())
? _engine.node_factory()->plugin(_plugin_uri.str())
: _engine.node_factory()->plugin(_plugin_type, _plugin_lib, _plugin_label);
diff --git a/src/engine/events/CreatePort.cpp b/src/engine/events/CreatePort.cpp
index b12f25dc..f1656019 100644
--- a/src/engine/events/CreatePort.cpp
+++ b/src/engine/events/CreatePort.cpp
@@ -98,6 +98,7 @@ CreatePort::pre_process()
if (_patch->parent())
_patch_port->set_property(uris.rdf_instanceOf, _patch_port->meta_uri());
+ _patch_port->properties().insert(_properties.begin(), _properties.end());
_patch_port->meta().properties().insert(_properties.begin(), _properties.end());
if (_patch_port) {
diff --git a/src/gui/GladeFactory.cpp b/src/gui/GladeFactory.cpp
index 41fcffc4..6a00a8b5 100644
--- a/src/gui/GladeFactory.cpp
+++ b/src/gui/GladeFactory.cpp
@@ -54,11 +54,11 @@ GladeFactory::find_glade_file()
Glib::RefPtr<Gnome::Glade::Xml>
GladeFactory::new_glade_reference(const string& toplevel_widget)
{
- if (glade_filename == "")
+ if (glade_filename.empty())
find_glade_file();
try {
- if (toplevel_widget == "")
+ if (toplevel_widget.empty())
return Gnome::Glade::Xml::create(glade_filename);
else
return Gnome::Glade::Xml::create(glade_filename, toplevel_widget.c_str());
diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp
index cdf6cc1f..1b8b4859 100644
--- a/src/gui/LoadPluginWindow.cpp
+++ b/src/gui/LoadPluginWindow.cpp
@@ -332,10 +332,10 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter)
bool polyphonic = _polyphonic_checkbutton->get_active();
string name = _node_name_entry->get_text();
- if (name == "" || name == NAME_ENTRY_MULTI_STRING)
+ if (name.empty() || name == NAME_ENTRY_MULTI_STRING)
name = generate_module_name(plugin, _plugin_name_offset);
- if (name == "" || !Symbol::is_valid(name)) {
+ if (name.empty() || !Symbol::is_valid(name)) {
Gtk::MessageDialog dialog(*this,
"Unable to chose a default name for this node. Please enter a name.",
false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index cb6a06af..58366377 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -141,7 +141,7 @@ NodeModule::show_human_names(bool b)
} else {
Glib::ustring hn = node()->plugin_model()->port_human_name(
port->model()->index());
- if (hn != "")
+ if (!hn.empty())
label = hn;
}
}
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp
index cd2469d1..bd215037 100644
--- a/src/gui/PatchCanvas.cpp
+++ b/src/gui/PatchCanvas.cpp
@@ -372,7 +372,7 @@ PatchCanvas::add_node(SharedPtr<NodeModel> nm)
} else {
module = NodeModule::create(shared_this, nm, _human_names);
const PluginModel* plugm = dynamic_cast<const PluginModel*>(nm->plugin());
- if (plugm && plugm->icon_path() != "")
+ if (plugm && !plugm->icon_path().empty())
module->set_icon(App::instance().icon_from_path(plugm->icon_path(), 100));
}
@@ -662,7 +662,7 @@ PatchCanvas::paste()
props.insert(make_pair(uris.ingen_polyphony, Raul::Atom(int32_t(_patch->poly()))));
clipboard.put(Path(), props);
size_t first_slash;
- while (to_create != "/" && to_create != ""
+ while (to_create != "/" && !to_create.empty()
&& (first_slash = to_create.find("/")) != string::npos) {
created += to_create.substr(0, first_slash);
assert(Path::is_valid(created));
diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp
index 796837e3..9efd4887 100644
--- a/src/gui/PatchWindow.cpp
+++ b/src/gui/PatchWindow.cpp
@@ -324,7 +324,7 @@ PatchWindow::show_port_status(PortModel* port, const Raul::Atom& value)
const PluginModel* plugin = dynamic_cast<const PluginModel*>(parent->plugin());
if (plugin) {
const string& human_name = plugin->port_human_name(port->index());
- if (human_name != "")
+ if (!human_name.empty())
msg << " (" << human_name << ")";
}
}
diff --git a/src/gui/RenameWindow.cpp b/src/gui/RenameWindow.cpp
index f7fa86a9..1c3cbe85 100644
--- a/src/gui/RenameWindow.cpp
+++ b/src/gui/RenameWindow.cpp
@@ -99,7 +99,7 @@ void
RenameWindow::label_changed()
{
const string& label = _label_entry->get_text();
- if (label == "") {
+ if (label.empty()) {
_message_label->set_text("Label must be at least 1 character");
_ok_button->property_sensitive() = false;
} else {
@@ -141,7 +141,7 @@ RenameWindow::ok_clicked()
}
}
- if (label != "" && (!name_atom.is_valid() || label != name_atom.get_string())) {
+ if (!label.empty() && (!name_atom.is_valid() || label != name_atom.get_string())) {
App::instance().engine()->set_property(path, uris.lv2_name, Atom(label));
}
diff --git a/src/scripts/python/ingen.py b/src/scripts/python/ingen.py
index 07698719..d6408406 100644
--- a/src/scripts/python/ingen.py
+++ b/src/scripts/python/ingen.py
@@ -312,7 +312,7 @@ class Environment:
elements = path.split("/")
currentPatch = None
for element in elements:
- if element == "":
+ if element.empty():
currentPatch = self.omPatch
else:
currentPatch = currentPatch.getPatch(element,mustexist)
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index bcc45fd1..92fe78d1 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -66,9 +66,9 @@ relative_uri(Glib::ustring base, const Glib::ustring uri, bool leading_slash)
else
ret = uri;
- if (leading_slash && (ret == "" || ret[0] != '/'))
+ if (leading_slash && (ret.empty() || ret[0] != '/'))
ret = "/" + ret;
- else if (!leading_slash && ret != "" && ret[0] == '/')
+ else if (!leading_slash && !ret.empty() && ret[0] == '/')
ret = ret.substr(1);
return ret;
@@ -137,7 +137,7 @@ Parser::parse_string(
Redland::Model model(*world->rdf_world, str.c_str(), str.length(), base_uri);
LOG(info) << "Parsing " << (data_path ? data_path->str() : "*") << " from string";
- if (base_uri != "")
+ if (!base_uri.empty())
LOG(info) << " (base " << base_uri << ")";
LOG(info) << endl;
@@ -189,7 +189,7 @@ Parser::parse_update(
if (obj_uri.find(":") == string::npos)
obj_uri = Path(obj_uri).str();
obj_uri = relative_uri(base_uri, obj_uri, true);
- if (key != "")
+ if (!key.empty())
target->set_property(string("path:") + obj_uri, key, a);
}
@@ -276,7 +276,7 @@ Parser::parse(
const Glib::ustring subject_uri_tok = Glib::ustring("<").append(subject).append(">");
if (is_object) {
- if (path_str == "" || path_str[0] != '/')
+ if (path_str.empty() || path_str[0] != '/')
path_str = "/" + path_str;
if (!Path::is_valid(path_str)) {
@@ -375,7 +375,7 @@ Parser::parse_patch(
} else { // Guess symbol from base URI (filename) if we need to
symbol = base_uri.substr(base_uri.find_last_of("/") + 1);
symbol = symbol.substr(0, symbol.find("."));
- if (symbol != "")
+ if (!symbol.empty())
symbol = Path::nameify(symbol);
}
@@ -726,7 +726,7 @@ Parser::parse_properties(
const Redland::Node& val = (*i)["val"];
if (skip_property((*i)["key"]))
continue;
- if (key != "" && val.type() != Redland::Node::BLANK)
+ if (!key.empty() && val.type() != Redland::Node::BLANK)
properties.insert(make_pair(key, AtomRDF::node_to_atom(model, val)));
}
diff --git a/src/shared/ClashAvoider.cpp b/src/shared/ClashAvoider.cpp
index a3e54957..c6aec06d 100644
--- a/src/shared/ClashAvoider.cpp
+++ b/src/shared/ClashAvoider.cpp
@@ -97,7 +97,7 @@ ClashAvoider::map_path(const Raul::Path& in)
} else {
string parent_str = in.parent().base();
parent_str = parent_str.substr(0, parent_str.find_last_of("/"));
- if (parent_str == "")
+ if (parent_str.empty())
parent_str = "/";
debug << "PARENT: " << parent_str << endl;
}