Skip to content

Fix the design of VampPluginLoader#1282

Merged
daschuer merged 6 commits intomixxxdj:masterfrom
uklotzde:vamp_init
Jun 11, 2017
Merged

Fix the design of VampPluginLoader#1282
daschuer merged 6 commits intomixxxdj:masterfrom
uklotzde:vamp_init

Conversation

@uklotzde
Copy link
Copy Markdown
Contributor

Backported from #1276

Kudos to @JosepMaJAZ for the hint!
@daschuer One minor quick win ;)

Comment thread src/analyzer/vamp/vamppluginloader.cpp Outdated
// VAMP_PATH environment variable is already set by the user, then this
// method appends to that.
void initPluginPaths() {
const QLatin1String pathEnv(getenv("VAMP_PATH"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure this is a latin1 string on all targets? I consider this to be a local 8 bit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mm... the older implementation created a QString from the const char* returned.
The documentation does not say what it contains, but probably it is locale-dependant:
http://www.cplusplus.com/reference/cstdlib/getenv/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QString(const char*) isn't any better than QLatin1String(const char*), only less efficient. Maybe we should use fromLocal8Bit() instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes fromLocal8Bit() should be correct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will also use qgetenv()

Comment thread src/analyzer/vamp/vamppluginloader.cpp Outdated
}
#endif

QString newPath = pathElements.join(PATH_SEPARATOR);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason to spit an join instead of just append?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it is in order to avoid implementing the special case of not adding it to the last entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like splitting doesn't make any sense as long as we don't access or replace individual pathElements.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not my focus ;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing to block this PR ;-)

Comment thread src/analyzer/vamp/vamppluginloader.cpp Outdated

Logger kLogger("VampPluginLoader");

Vamp::HostExt::PluginLoader* pPluginLoader = nullptr;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have stumbled over this, because it is hard to distinguish from a local. Can't we use just instance()?
Isn't a name space global the same as a static variable? So we could use the s prefix?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use a 'g' prefix for global (although visibility at the global scope is restricted to this file).

Copy link
Copy Markdown
Member

@daschuer daschuer Jun 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this again, I think "s" prefix can be used here as well.
A anonymous name spaces is the preferred replacement for the multi featured (ambigious) static keyword. So the s can remain even if we fully switch to namespaces.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had exactly the same idea of using "s_" and mentioned why in the commit message ;)

@uklotzde
Copy link
Copy Markdown
Contributor Author

I will fix the remaining issues to make this code more robust, finally ;)

@uklotzde
Copy link
Copy Markdown
Contributor Author

Revised

@daschuer
Copy link
Copy Markdown
Member

CI is done, so I can merge. Thank you for working on it. LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants