Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micro optimize ControlObject::set() double vs double& #29

Merged
merged 1 commit into from
Jun 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/control/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,22 @@ void ControlDoublePrivate::reset() {
set(defaultValue, NULL);
}

void ControlDoublePrivate::set(const double& value, QObject* pSender) {
void ControlDoublePrivate::set(double value, QObject* pSender) {
if (m_bIgnoreNops && get() == value) {
return;
}

double dValue = value;
// If the behavior says to ignore the set, ignore it.
ControlNumericBehavior* pBehavior = m_pBehavior;
if (pBehavior && !pBehavior->setFilter(&dValue)) {
if (pBehavior && !pBehavior->setFilter(&value)) {
return;
}
m_value.setValue(dValue);
emit(valueChanged(dValue, pSender));
m_value.setValue(value);
emit(valueChanged(value, pSender));

if (m_bTrack) {
Stat::track(m_trackKey, static_cast<Stat::StatType>(m_trackType),
static_cast<Stat::ComputeFlags>(m_trackFlags), dValue);
static_cast<Stat::ComputeFlags>(m_trackFlags), value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/control/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ControlDoublePrivate : public QObject {
}

// Sets the control value.
void set(const double& value, QObject* pSender);
void set(double value, QObject* pSender);
// Gets the control value.
double get() const;
// Resets the control value to its default.
Expand Down
2 changes: 1 addition & 1 deletion src/controlobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void ControlObject::reset() {
}
}

void ControlObject::set(const double& value) {
void ControlObject::set(double value) {
if (m_pControl) {
m_pControl->set(value, this);
}
Expand Down
2 changes: 1 addition & 1 deletion src/controlobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ControlObject : public QObject {
// Instantly returns the value of the ControlObject
static double get(const ConfigKey& key);
// Sets the ControlObject value
void set(const double& value);
void set(double value);
// Instantly sets the value of the ControlObject
static void set(const ConfigKey& key, const double& value);
// Sets the default value
Expand Down