summaryrefslogtreecommitdiffstats
path: root/include/raul
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-19 11:58:34 +0100
committerDavid Robillard <d@drobilla.net>2020-12-19 12:02:24 +0100
commit2a09c19703b242aaf693e5b52a70c1ad65332119 (patch)
treefcaf9fdffa4dcb80a74fc4e1b2c90e81e7e20fb6 /include/raul
parent5680e5900f6fb89ec66af6480a7d125fc8960552 (diff)
downloadraul-2a09c19703b242aaf693e5b52a70c1ad65332119.tar.gz
raul-2a09c19703b242aaf693e5b52a70c1ad65332119.tar.bz2
raul-2a09c19703b242aaf693e5b52a70c1ad65332119.zip
Avoid "else" after "return"
Diffstat (limited to 'include/raul')
-rw-r--r--include/raul/DoubleBuffer.hpp4
-rw-r--r--include/raul/Path.hpp21
-rw-r--r--include/raul/RingBuffer.hpp16
-rw-r--r--include/raul/Socket.hpp5
-rw-r--r--include/raul/Symbol.hpp4
5 files changed, 30 insertions, 20 deletions
diff --git a/include/raul/DoubleBuffer.hpp b/include/raul/DoubleBuffer.hpp
index 73b5565..f6ab826 100644
--- a/include/raul/DoubleBuffer.hpp
+++ b/include/raul/DoubleBuffer.hpp
@@ -62,7 +62,9 @@ public:
_vals[1] = std::move(new_val);
_state.store(State::WRITE_READ, std::memory_order_release);
return true;
- } else if (transition(State::WRITE_READ, State::LOCK_READ)) {
+ }
+
+ if (transition(State::WRITE_READ, State::LOCK_READ)) {
// Locked _vals[0] for writing
_vals[0] = std::move(new_val);
_state.store(State::READ_WRITE, std::memory_order_release);
diff --git a/include/raul/Path.hpp b/include/raul/Path.hpp
index f0168b7..4fb3da1 100644
--- a/include/raul/Path.hpp
+++ b/include/raul/Path.hpp
@@ -95,10 +95,14 @@ public:
for (size_t i = 1; i < str.length(); ++i) {
if (!is_valid_char(str[i])) {
return false; // All characters must be /, _, a-z, A-Z, 0-9
- } else if (str[i - 1] == '/') {
+ }
+
+ if (str[i - 1] == '/') {
if (str[i] == '/') {
return false; // Must not contain "//"
- } else if (!Symbol::is_valid_start_char(str[i])) {
+ }
+
+ if (!Symbol::is_valid_start_char(str[i])) {
return false; // Invalid symbol start character (digit)
}
}
@@ -145,12 +149,11 @@ public:
inline Path parent() const {
if (is_root()) {
return *this;
- } else {
- const size_t first_sep = find('/');
- const size_t last_sep = find_last_of('/');
- return (first_sep == last_sep)
- ? Path("/") : Path(substr(0, last_sep));
}
+
+ const size_t first_sep = find('/');
+ const size_t last_sep = find_last_of('/');
+ return (first_sep == last_sep) ? Path("/") : Path(substr(0, last_sep));
}
/** Return a child Path of this path. */
@@ -171,9 +174,9 @@ public:
inline std::string base() const {
if (is_root()) {
return *this;
- } else {
- return *this + '/';
}
+
+ return *this + '/';
}
/** Return the lowest common ancestor of a and b. */
diff --git a/include/raul/RingBuffer.hpp b/include/raul/RingBuffer.hpp
index 176fe92..b83f442 100644
--- a/include/raul/RingBuffer.hpp
+++ b/include/raul/RingBuffer.hpp
@@ -105,9 +105,9 @@ public:
std::atomic_thread_fence(std::memory_order_acquire);
_read_head = (r + size) & _size_mask;
return size;
- } else {
- return 0;
}
+
+ return 0;
}
/**
@@ -170,19 +170,21 @@ private:
inline uint32_t write_space_internal(uint32_t r, uint32_t w) const {
if (r == w) {
return _size - 1;
- } else if (r < w) {
+ }
+
+ if (r < w) {
return ((r - w + _size) & _size_mask) - 1;
- } else {
- return (r - w) - 1;
}
+
+ return (r - w) - 1;
}
inline uint32_t read_space_internal(uint32_t r, uint32_t w) const {
if (r < w) {
return w - r;
- } else {
- return (w - r + _size) & _size_mask;
}
+
+ return (w - r + _size) & _size_mask;
}
inline uint32_t peek_internal(uint32_t r, uint32_t w,
diff --git a/include/raul/Socket.hpp b/include/raul/Socket.hpp
index 66b5a45..74a1595 100644
--- a/include/raul/Socket.hpp
+++ b/include/raul/Socket.hpp
@@ -159,7 +159,9 @@ Socket::set_addr(const std::string& uri)
_addr = reinterpret_cast<sockaddr*>(uaddr);
_addr_len = sizeof(struct sockaddr_un);
return true;
- } else if (_type == Type::TCP && uri.find("://") != std::string::npos) {
+ }
+
+ if (_type == Type::TCP && uri.find("://") != std::string::npos) {
const std::string authority = uri.substr(uri.find("://") + 3);
const size_t port_sep = authority.find(':');
if (port_sep == std::string::npos) {
@@ -184,6 +186,7 @@ Socket::set_addr(const std::string& uri)
freeaddrinfo(ainfo);
return true;
}
+
return false;
}
diff --git a/include/raul/Symbol.hpp b/include/raul/Symbol.hpp
index 4814334..4f762f8 100644
--- a/include/raul/Symbol.hpp
+++ b/include/raul/Symbol.hpp
@@ -120,9 +120,9 @@ public:
if (is_valid_start_char(out[0])) {
return Symbol(out);
- } else {
- return Symbol(std::string("_") + out);
}
+
+ return Symbol(std::string("_") + out);
}
};