From 7c19aa2a97c1e19b27b66c58a84c46489101950e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 4 Feb 2010 17:21:44 +0000 Subject: 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 --- src/client/DeprecatedLoader.cpp | 20 ++++++++++---------- src/client/HTTPClientReceiver.cpp | 6 +++--- src/client/PluginModel.cpp | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/client') 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 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); } -- cgit v1.2.1