mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -13,13 +13,19 @@ EntryNotifier::EntryNotifier(int inst, wpi::Logger& logger)
|
||||
m_local_notifiers = false;
|
||||
}
|
||||
|
||||
void EntryNotifier::Start() { DoStart(m_inst); }
|
||||
void EntryNotifier::Start() {
|
||||
DoStart(m_inst);
|
||||
}
|
||||
|
||||
bool EntryNotifier::local_notifiers() const { return m_local_notifiers; }
|
||||
bool EntryNotifier::local_notifiers() const {
|
||||
return m_local_notifiers;
|
||||
}
|
||||
|
||||
bool impl::EntryNotifierThread::Matches(const EntryListenerData& listener,
|
||||
const EntryNotification& data) {
|
||||
if (!data.value) return false;
|
||||
if (!data.value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Flags must be within requested flag set for this listener.
|
||||
// Because assign messages can result in both a value and flags update,
|
||||
@@ -29,17 +35,24 @@ bool impl::EntryNotifierThread::Matches(const EntryListenerData& listener,
|
||||
unsigned int flags = data.flags & ~(NT_NOTIFY_IMMEDIATE | NT_NOTIFY_LOCAL);
|
||||
unsigned int assign_both = NT_NOTIFY_UPDATE | NT_NOTIFY_FLAGS;
|
||||
if ((flags & assign_both) == assign_both) {
|
||||
if ((listen_flags & assign_both) == 0) return false;
|
||||
if ((listen_flags & assign_both) == 0) {
|
||||
return false;
|
||||
}
|
||||
listen_flags &= ~assign_both;
|
||||
flags &= ~assign_both;
|
||||
}
|
||||
if ((flags & ~listen_flags) != 0) return false;
|
||||
if ((flags & ~listen_flags) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// must match local id or prefix
|
||||
if (listener.entry != 0 && data.entry != listener.entry) return false;
|
||||
if (listener.entry == 0 &&
|
||||
!wpi::StringRef(data.name).startswith(listener.prefix))
|
||||
if (listener.entry != 0 && data.entry != listener.entry) {
|
||||
return false;
|
||||
}
|
||||
if (listener.entry == 0 &&
|
||||
!wpi::StringRef(data.name).startswith(listener.prefix)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -47,28 +60,36 @@ bool impl::EntryNotifierThread::Matches(const EntryListenerData& listener,
|
||||
unsigned int EntryNotifier::Add(
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
StringRef prefix, unsigned int flags) {
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0) m_local_notifiers = true;
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0) {
|
||||
m_local_notifiers = true;
|
||||
}
|
||||
return DoAdd(callback, prefix, flags);
|
||||
}
|
||||
|
||||
unsigned int EntryNotifier::Add(
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
unsigned int local_id, unsigned int flags) {
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0) m_local_notifiers = true;
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0) {
|
||||
m_local_notifiers = true;
|
||||
}
|
||||
return DoAdd(callback, Handle(m_inst, local_id, Handle::kEntry), flags);
|
||||
}
|
||||
|
||||
unsigned int EntryNotifier::AddPolled(unsigned int poller_uid,
|
||||
wpi::StringRef prefix,
|
||||
unsigned int flags) {
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0) m_local_notifiers = true;
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0) {
|
||||
m_local_notifiers = true;
|
||||
}
|
||||
return DoAdd(poller_uid, prefix, flags);
|
||||
}
|
||||
|
||||
unsigned int EntryNotifier::AddPolled(unsigned int poller_uid,
|
||||
unsigned int local_id,
|
||||
unsigned int flags) {
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0) m_local_notifiers = true;
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0) {
|
||||
m_local_notifiers = true;
|
||||
}
|
||||
return DoAdd(poller_uid, Handle(m_inst, local_id, Handle::kEntry), flags);
|
||||
}
|
||||
|
||||
@@ -78,7 +99,9 @@ void EntryNotifier::NotifyEntry(unsigned int local_id, StringRef name,
|
||||
unsigned int only_listener) {
|
||||
// optimization: don't generate needless local queue entries if we have
|
||||
// no local listeners (as this is a common case on the server side)
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0 && !m_local_notifiers) return;
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0 && !m_local_notifiers) {
|
||||
return;
|
||||
}
|
||||
DEBUG0("notifying '" << name << "' (local=" << local_id
|
||||
<< "), flags=" << flags);
|
||||
Send(only_listener, 0, Handle(m_inst, local_id, Handle::kEntry).handle(),
|
||||
|
||||
Reference in New Issue
Block a user