[libcalamares] Tighten up types

- If we're converting a YAML map to a QVariant (Map), may as well
  express that in the types. This makes the return from, say,
  `yamlMapToVariant()` cheaper, but incurs conversion in
  `yamlToVariant()` .. previously the place for costs was
  swapped around.
- For those cases that want-and-expect a Map, or List, this makes
  the calls slightly cheaper. For the generic case, the costs move
  around internally.
main
Adriaan de Groot 5 years ago
parent 2eb84e2de1
commit 1678a03cb3

@ -89,7 +89,7 @@ yamlScalarToVariant( const YAML::Node& scalarNode )
} }
QVariant QVariantList
yamlSequenceToVariant( const YAML::Node& sequenceNode ) yamlSequenceToVariant( const YAML::Node& sequenceNode )
{ {
QVariantList vl; QVariantList vl;
@ -101,7 +101,7 @@ yamlSequenceToVariant( const YAML::Node& sequenceNode )
} }
QVariant QVariantMap
yamlMapToVariant( const YAML::Node& mapNode ) yamlMapToVariant( const YAML::Node& mapNode )
{ {
QVariantMap vm; QVariantMap vm;

@ -22,6 +22,8 @@
#include <QStringList> #include <QStringList>
#include <QVariant> #include <QVariant>
#include <QVariantList>
#include <QVariantMap>
class QByteArray; class QByteArray;
class QFileInfo; class QFileInfo;
@ -60,8 +62,8 @@ QVariantMap loadYaml( const QFileInfo&, bool* ok = nullptr );
QVariant yamlToVariant( const YAML::Node& node ); QVariant yamlToVariant( const YAML::Node& node );
QVariant yamlScalarToVariant( const YAML::Node& scalarNode ); QVariant yamlScalarToVariant( const YAML::Node& scalarNode );
QVariant yamlSequenceToVariant( const YAML::Node& sequenceNode ); QVariantList yamlSequenceToVariant( const YAML::Node& sequenceNode );
QVariant yamlMapToVariant( const YAML::Node& mapNode ); QVariantMap yamlMapToVariant( const YAML::Node& mapNode );
/// @brief Returns all the elements of @p listNode in a StringList /// @brief Returns all the elements of @p listNode in a StringList
QStringList yamlToStringList( const YAML::Node& listNode ); QStringList yamlToStringList( const YAML::Node& listNode );

Loading…
Cancel
Save