-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove offensive language (Pt. 3) #11960
Draft
Holzhaus
wants to merge
10
commits into
mixxxdj:2.5
Choose a base branch
from
Holzhaus:remove-offensive-language-pt3
base: 2.5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d2f2eb8
refactor: Rename `[Master]` to `[Main]` and add group alias
Holzhaus 0e97149
refactor: Add group alias support for effect chains/slots
Holzhaus 8a48f12
refactor: Use `[Main]` group in entire C++ code
Holzhaus c68577a
chore(keyboard): Use `[Main]` group in keyboard mappings
Holzhaus 09dbc8f
chore(qml): Use `[Main]` group in QML skin
Holzhaus 40bdb8b
refactor(skins): Use `[Main]` group in all skins
Holzhaus 5ad20c2
refactor(tools): Use `[Main]` group in `make_xone.py` script
Holzhaus 87763ce
refactor(controllers): Use `[Main]` group in built-in mappings
Holzhaus 7722a5a
refactor: Rename `[MasterOutput]` to `[MainOutput]` and add group alias
Holzhaus beb9ba1
refactor(skins): Use `[MainOutput]` group in all skins
Holzhaus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,11 @@ QHash<ConfigKey, QWeakPointer<ControlDoublePrivate>> s_qCOHash | |
QHash<ConfigKey, ConfigKey> s_qCOAliasHash | ||
GUARDED_BY(s_qCOHashMutex); | ||
|
||
/// Hash of aliases between group names. Solely used for looking up the first | ||
/// alias associated with a name when adding a new control. | ||
QHash<QString, QString> s_qCOGroupAliasHash | ||
GUARDED_BY(s_qCOHashMutex); | ||
|
||
/// is used instead of a nullptr, helps to omit null checks everywhere | ||
QWeakPointer<ControlDoublePrivate> s_pDefaultCO; | ||
} // namespace | ||
|
@@ -125,6 +130,32 @@ void ControlDoublePrivate::insertAlias(const ConfigKey& alias, const ConfigKey& | |
s_qCOHash.insert(alias, pControl); | ||
} | ||
|
||
// static | ||
void ControlDoublePrivate::insertGroupAlias( | ||
const QString& aliasGroup, const QString& originalGroup) { | ||
MMutexLocker locker(&s_qCOHashMutex); | ||
|
||
// Check if there are any pre-existing control with the group that we want | ||
// to add an alias for and control aliases for them. | ||
for (auto it = s_qCOHash.cbegin(), end = s_qCOHash.cend(); it != end; ++it) { | ||
const auto originalKey = it.key(); | ||
if (originalKey.group != originalGroup) { | ||
continue; | ||
} | ||
|
||
QSharedPointer<ControlDoublePrivate> pControl = it.value(); | ||
if (pControl.isNull()) { | ||
continue; | ||
} | ||
|
||
const auto aliasKey = ConfigKey(aliasGroup, originalKey.item); | ||
s_qCOAliasHash.insert(originalKey, aliasKey); | ||
s_qCOHash.insert(aliasKey, pControl); | ||
} | ||
|
||
s_qCOGroupAliasHash.insert(originalGroup, aliasGroup); | ||
} | ||
|
||
// static | ||
QSharedPointer<ControlDoublePrivate> ControlDoublePrivate::getControl( | ||
const ConfigKey& key, | ||
|
@@ -175,9 +206,22 @@ QSharedPointer<ControlDoublePrivate> ControlDoublePrivate::getControl( | |
bTrack, | ||
bPersist, | ||
defaultValue)); | ||
const MMutexLocker locker(&s_qCOHashMutex); | ||
s_qCOHashMutex.lock(); | ||
//qDebug() << "ControlDoublePrivate::s_qCOHash.insert(" << key.group << "," << key.item << ")"; | ||
s_qCOHash.insert(key, pControl); | ||
|
||
// Check if the control's group is aliased. If so, add a corresponding | ||
// alias for this control. | ||
auto it = s_qCOGroupAliasHash.constFind(key.group); | ||
if (it != s_qCOGroupAliasHash.constEnd()) { | ||
QString aliasGroup = it.value(); | ||
auto aliasKey = ConfigKey(aliasGroup, key.item); | ||
s_qCOHashMutex.unlock(); | ||
insertAlias(aliasKey, key); | ||
} else { | ||
s_qCOHashMutex.unlock(); | ||
} | ||
Comment on lines
+219
to
+223
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer if we used a locker and just manually unlocked just before. |
||
|
||
return pControl; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this get expensive if the group is large? would it be better to do the aliasing for the group on lookup instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That way, as part of the lookup we could also print a warning if the alias was used instead of the non-aliased group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean memory-wise? It adds a regular alias for every member in a group, but it shouldn't be that much of an issue. In terms of runtime performance, it shouldn't be an issue because lookups are only performed when a new CO is created and it's O(1).
True, this could be worth considering. I'll have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, if the group is large, this could bloat the table quite a bit. Yes, lookups are$O(1)$ but creating a group alias and creating COs becomes $O(n)$ (where $n$ is size of the group in the former case and the number of alias groups in the latter). The increased table size would cause the usual slowdowns associated with high memory consumption (data cache misses, more yields to the OS for more memory, more table relocations since it grows faster / more often, etc).
Doing the aliasing lookup would avoid that and only be worse performing on the unhappy path (probing via alias group, if CO exists return (happy path) otherwise lookup primary group name, probe again using primary group name, print warning, etc).