mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-10 00:00:19 +02:00
The argument loader was loading configuration from the arguments twice. The use of the argument loader needs to preload the arguments before being handed off to the config system. This way we can pull remaining arguments that get passed to the guest application. Due to this, `Load` was getting called twice, once in the constructor and once in the Config system. This was causing the backend to allocate twice as much memory since the second load appends the arguments to a fextl::list internally. Not really any functional change but it was causing some heartburn with some changes I was working on.
50 lines
1.0 KiB
C++
50 lines
1.0 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#pragma once
|
|
|
|
#include <FEXCore/Config/Config.h>
|
|
#include <FEXCore/fextl/string.h>
|
|
#include <FEXCore/fextl/vector.h>
|
|
|
|
namespace FEX::ArgLoader {
|
|
class ArgLoader final : public FEXCore::Config::Layer {
|
|
public:
|
|
enum class LoadType {
|
|
WITH_FEXLOADER_PARSER,
|
|
WITHOUT_FEXLOADER_PARSER,
|
|
};
|
|
|
|
explicit ArgLoader(LoadType Type, int argc, char** argv)
|
|
: FEXCore::Config::Layer(FEXCore::Config::LayerType::LAYER_ARGUMENTS)
|
|
, Type {Type}
|
|
, argc {argc}
|
|
, argv {argv} {
|
|
PreLoad();
|
|
}
|
|
|
|
void Load() override {
|
|
// Intentional no-op.
|
|
}
|
|
void PreLoad();
|
|
void LoadWithoutArguments();
|
|
fextl::vector<fextl::string> Get() {
|
|
return RemainingArgs;
|
|
}
|
|
fextl::vector<fextl::string> GetParsedArgs() {
|
|
return ProgramArguments;
|
|
}
|
|
|
|
LoadType GetLoadType() const {
|
|
return Type;
|
|
}
|
|
|
|
private:
|
|
LoadType Type;
|
|
int argc {};
|
|
char** argv {};
|
|
|
|
fextl::vector<fextl::string> RemainingArgs {};
|
|
fextl::vector<fextl::string> ProgramArguments {};
|
|
};
|
|
|
|
} // namespace FEX::ArgLoader
|