Skip to content

Commit

Permalink
libcore: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jun 2, 2016
1 parent 7ad0137 commit 94c12c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions doomsday/sdk/libcore/include/de/data/info.h
Expand Up @@ -220,11 +220,12 @@ class DENG2_PUBLIC Info
* @param name Name of a key element in the block. This may also be
* a path where a color ':' is used for separating
* element names.
* @param defaultValue If the key is not found, this value is returned instead.
*
* @return Value of the key element. If the located element is not a
* key element, returns an empty string.
* key element, returns @a defaultValue.
*/
Value keyValue(String const &name) const;
Value keyValue(String const &name, String const &defaultValue = String()) const;

/**
* Looks for an element based on a path where a colon ':' is used to
Expand Down
5 changes: 3 additions & 2 deletions doomsday/sdk/libcore/src/data/info.cpp
Expand Up @@ -741,10 +741,11 @@ Info::Element *Info::BlockElement::find(String const &name) const
return found.value();
}

Info::Element::Value Info::BlockElement::keyValue(String const &name) const
Info::Element::Value Info::BlockElement::keyValue(String const &name,
String const &defaultValue) const
{
Element *e = findByPath(name);
if (!e || !e->isKey()) return Value();
if (!e || !e->isKey()) return Value(defaultValue);
return e->as<KeyElement>().value();
}

Expand Down
8 changes: 5 additions & 3 deletions doomsday/sdk/libcore/src/filesys/packageloader.cpp
Expand Up @@ -32,6 +32,8 @@

namespace de {

static String const VAR_PACKAGE_VERSION("package.version");

DENG2_PIMPL(PackageLoader)
{
LoadedPackages loaded;
Expand Down Expand Up @@ -166,7 +168,7 @@ DENG2_PIMPL(PackageLoader)
if (idVer.second.isValid())
{
found.remove_if([&idVer] (File *f) {
Version const pkgVer = f->objectNamespace().gets("package.version");
Version const pkgVer = f->objectNamespace().gets(VAR_PACKAGE_VERSION);
return (pkgVer != idVer.second); // Ignore other versions.
});
// Did we run out of candidates?
Expand All @@ -177,8 +179,8 @@ DENG2_PIMPL(PackageLoader)
found.sort([] (File const *a, File const *b) -> bool
{
// The version must be specified using a format understood by Version.
Version const aVer(a->objectNamespace().gets("package.version"));
Version const bVer(b->objectNamespace().gets("package.version"));
Version const aVer(a->objectNamespace().gets(VAR_PACKAGE_VERSION));
Version const bVer(b->objectNamespace().gets(VAR_PACKAGE_VERSION));

if (aVer == bVer)
{
Expand Down

0 comments on commit 94c12c8

Please sign in to comment.