OGL/Render.cpp, InitDriverInfo(): Use std::string_view to eliminate string copies.

Consolidate the NVIDIA Tegra and non-Tegra checks into one branch.
This commit is contained in:
David Korth 2019-09-24 00:30:20 -04:00
parent 1d7f128693
commit 05101b251c
1 changed files with 16 additions and 13 deletions

View File

@ -144,28 +144,35 @@ static void APIENTRY ClearDepthf(GLfloat depthval)
static void InitDriverInfo()
{
std::string svendor = std::string(g_ogl_config.gl_vendor);
std::string srenderer = std::string(g_ogl_config.gl_renderer);
std::string sversion = std::string(g_ogl_config.gl_version);
const std::string_view svendor(g_ogl_config.gl_vendor);
const std::string_view srenderer(g_ogl_config.gl_renderer);
const std::string_view sversion(g_ogl_config.gl_version);
DriverDetails::Vendor vendor = DriverDetails::VENDOR_UNKNOWN;
DriverDetails::Driver driver = DriverDetails::DRIVER_UNKNOWN;
DriverDetails::Family family = DriverDetails::Family::UNKNOWN;
double version = 0.0;
// Get the vendor first
if (svendor == "NVIDIA Corporation" && srenderer != "NVIDIA Tegra")
if (svendor == "NVIDIA Corporation")
{
vendor = DriverDetails::VENDOR_NVIDIA;
if (srenderer != "NVIDIA Tegra")
{
vendor = DriverDetails::VENDOR_NVIDIA;
}
else
{
vendor = DriverDetails::VENDOR_TEGRA;
}
}
else if (svendor == "ATI Technologies Inc." || svendor == "Advanced Micro Devices, Inc.")
{
vendor = DriverDetails::VENDOR_ATI;
}
else if (std::string::npos != sversion.find("Mesa"))
else if (sversion.find("Mesa") != std::string::npos)
{
vendor = DriverDetails::VENDOR_MESA;
}
else if (std::string::npos != svendor.find("Intel"))
else if (svendor.find("Intel") != std::string::npos)
{
vendor = DriverDetails::VENDOR_INTEL;
}
@ -186,10 +193,6 @@ static void InitDriverInfo()
{
vendor = DriverDetails::VENDOR_IMGTEC;
}
else if (svendor == "NVIDIA Corporation" && srenderer == "NVIDIA Tegra")
{
vendor = DriverDetails::VENDOR_TEGRA;
}
else if (svendor == "Vivante Corporation")
{
vendor = DriverDetails::VENDOR_VIVANTE;
@ -238,8 +241,8 @@ static void InitDriverInfo()
else if (srenderer.find("Ivybridge") != std::string::npos)
family = DriverDetails::Family::INTEL_IVY;
}
else if (std::string::npos != srenderer.find("AMD") ||
std::string::npos != srenderer.find("ATI"))
else if (srenderer.find("AMD") != std::string::npos ||
srenderer.find("ATI") != std::string::npos)
{
driver = DriverDetails::DRIVER_R600;
}