commit dc31a93cdc5221d5c4ea72906368afd936d4db79
parent 0577045c5d3e3d2d2520247c36e29108e0918e35
Author: cfillion <cfillion@users.noreply.github.com>
Date: Mon, 1 Apr 2019 17:42:24 -0400
constexpr-ify static arrays
Diffstat:
13 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/about.cpp b/src/about.cpp
@@ -135,7 +135,7 @@ void About::setDelegate(const DelegatePtr &delegate, const bool focus)
m_delegate = nullptr;
m_links.clear();
- const int controls[] = {
+ constexpr int controls[] {
IDC_ABOUT,
IDC_MENU,
IDC_LIST,
@@ -544,7 +544,7 @@ void AboutPackageDelegate::init(About *dialog)
void AboutPackageDelegate::updateList(const int index)
{
- const std::pair<Source::Section, const char *> sectionMap[] = {
+ constexpr std::pair<Source::Section, const char *> sectionMap[] {
{Source::MainSection, "Main"},
{Source::MIDIEditorSection, "MIDI Editor"},
{Source::MIDIInlineEditorSection, "MIDI Inline Editor"},
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -313,7 +313,7 @@ void Browser::updateDisplayLabel()
void Browser::displayButton()
{
- static std::pair<const char *, Package::Type> types[]{
+ constexpr std::pair<const char *, Package::Type> types[] {
{"&Automation Items", Package::AutomationItemType},
{"&Effects", Package::EffectType},
{"E&xtensions", Package::ExtensionType},
diff --git a/src/config.cpp b/src/config.cpp
@@ -95,7 +95,7 @@ void Config::restoreDefaultRemotes()
self.setEnabled(true);
remotes.add(self);
- const Remote repos[] = {
+ const Remote repos[] {
{"ReaTeam Scripts",
"https://github.com/ReaTeam/ReaScripts/raw/master/index.xml"},
{"ReaTeam JSFX",
diff --git a/src/main.cpp b/src/main.cpp
@@ -31,7 +31,7 @@ static bool loadAPI(void *(*getFunc)(const char *))
{
struct ApiFunc { void **ptr; const char *name; bool required; };
- const ApiFunc funcs[] = {
+ const ApiFunc funcs[] {
REQUIRED_API(Splash_GetWnd), // v4.7
REQUIRED_API(AddExtensionsMainMenu),
diff --git a/src/package.cpp b/src/package.cpp
@@ -25,7 +25,7 @@
Package::Type Package::getType(const char *type)
{
- const std::pair<const char *, Type> map[]{
+ constexpr std::pair<const char *, Type> map[] {
{"script", ScriptType},
{"extension", ExtensionType},
{"effect", EffectType},
diff --git a/src/platform.cpp b/src/platform.cpp
@@ -22,7 +22,7 @@
auto Platform::parse(const char *platform) -> Enum
{
- const std::pair<const char *, Enum> map[]{
+ constexpr std::pair<const char *, Enum> map[] {
{"all", GenericPlatform},
{"windows", WindowsPlatform},
diff --git a/src/report.cpp b/src/report.cpp
@@ -36,7 +36,7 @@ void Report::onInit()
Win32::setWindowText(getControl(IDC_REPORT), m_pages[i].c_str());
};
- const ReceiptPage pages[] = {
+ const ReceiptPage pages[] {
m_receipt->installedPage(),
m_receipt->removedPage(),
m_receipt->exportedPage(),
diff --git a/src/source.cpp b/src/source.cpp
@@ -24,7 +24,7 @@
auto Source::getSection(const char *name) -> Section
{
- const std::pair<const char *, Section> map[]{
+ constexpr std::pair<const char *, Section> map[] {
{"main", MainSection},
{"midi_editor", MIDIEditorSection},
{"midi_inlineeditor", MIDIInlineEditorSection},
diff --git a/src/transaction.cpp b/src/transaction.cpp
@@ -249,7 +249,7 @@ void Transaction::registerQueued()
void Transaction::registerScript(const HostTicket ®, const bool isLastCall)
{
- const std::pair<Source::Section, int> sectionMap[] = {
+ constexpr std::pair<Source::Section, int> sectionMap[] {
{Source::MainSection, 0},
{Source::MIDIEditorSection, 32060},
{Source::MIDIEventListEditorSection, 32061},
diff --git a/test/package.cpp b/test/package.cpp
@@ -7,7 +7,7 @@
static const char *M = "[package]";
TEST_CASE("package type from string", M) {
- const std::pair<const char *, Package::Type> tests[] = {
+ constexpr std::pair<const char *, Package::Type> tests[] {
{"yoyo", Package::UnknownType},
{"script", Package::ScriptType},
{"extension", Package::ExtensionType},
@@ -27,7 +27,7 @@ TEST_CASE("package type from string", M) {
}
TEST_CASE("package type to string", M) {
- const std::pair<Package::Type, std::string> tests[] = {
+ constexpr std::pair<Package::Type, const char *> tests[] {
{Package::UnknownType, "Unknown"},
{Package::ScriptType, "Script"},
{Package::ExtensionType, "Extension"},
diff --git a/test/platform.cpp b/test/platform.cpp
@@ -48,7 +48,7 @@ TEST_CASE("platform from string", M) {
}
TEST_CASE("test platform", M) {
- const std::pair<Platform, bool> tests[] = {
+ const std::pair<Platform, bool> tests[] {
{Platform::GenericPlatform, true},
#ifdef __APPLE__
diff --git a/test/remote.cpp b/test/remote.cpp
@@ -15,7 +15,7 @@ TEST_CASE("construct remote", M) {
TEST_CASE("remote name validation", M) {
SECTION("invalid") {
- const std::string invalidNames[] = {
+ const std::string invalidNames[] {
"",
"ab/cd",
"ab\\cd",
@@ -47,7 +47,7 @@ TEST_CASE("remote name validation", M) {
}
SECTION("valid") {
- const std::string validNames[] = {
+ const std::string validNames[] {
"1234",
"hello world",
"hello_world",
@@ -69,7 +69,7 @@ TEST_CASE("remote name validation", M) {
TEST_CASE("remote url validation", M) {
SECTION("invalid") {
- const std::string invalidUrls[] = {
+ const std::string invalidUrls[] {
"",
"hello world", // space should be %20
};
diff --git a/test/source.cpp b/test/source.cpp
@@ -130,7 +130,7 @@ TEST_CASE("empty source url", M) {
TEST_CASE("source target path", M) {
MAKE_VERSION;
- const std::pair<Package::Type, std::string> tests[] = {
+ constexpr std::pair<Package::Type, const char *> tests[] {
{Package::ScriptType, "Scripts/Index Name/Category Name/file.name"},
{Package::EffectType, "Effects/Index Name/Category Name/file.name"},
{Package::ExtensionType, "UserPlugins/file.name"},