Make some global string pointers const, not just the strings.

Minor cleanup.
This commit is contained in:
Henrik Rydgård 2023-12-28 14:00:01 +01:00
parent f22249cef5
commit e3177ac870
30 changed files with 97 additions and 97 deletions

View File

@ -537,7 +537,7 @@ void ARMXEmitter::MOVI2R(ARMReg reg, u32 val, bool optimize)
}
}
static const char *armRegStrings[] = {
static const char *const armRegStrings[] = {
"r0","r1","r2","r3",
"r4","r5","r6","r7",
"r8","r9","r10","r11",

View File

@ -646,7 +646,7 @@ void ResetGLExtensions() {
g_all_egl_extensions.clear();
}
static const char *glsl_fragment_prelude =
static const char * const glsl_fragment_prelude =
"#ifdef GL_ES\n"
"precision mediump float;\n"
"#endif\n";

View File

@ -74,7 +74,7 @@ struct Builtin {
const char *replacement;
};
static const char *cbufferDecl = R"(
static const char * const cbufferDecl = R"(
cbuffer data : register(b0) {
float2 u_texelDelta;
float2 u_pixelDelta;
@ -85,13 +85,13 @@ cbuffer data : register(b0) {
};
)";
static const char *vulkanPrologue =
static const char * const vulkanPrologue =
R"(#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
)";
static const char *vulkanUboDecl = R"(
static const char * const vulkanUboDecl = R"(
layout (std140, set = 0, binding = 0) uniform Data {
vec2 u_texelDelta;
vec2 u_pixelDelta;
@ -102,7 +102,7 @@ layout (std140, set = 0, binding = 0) uniform Data {
};
)";
static const char *d3d9RegisterDecl = R"(
static const char * const d3d9RegisterDecl = R"(
float4 gl_HalfPixel : register(c0);
float2 u_texelDelta : register(c1);
float2 u_pixelDelta : register(c2);

View File

@ -35,7 +35,7 @@ using namespace PPSSPP_VK;
VulkanLogOptions g_LogOptions;
static const char *validationLayers[] = {
static const char * const validationLayers[] = {
"VK_LAYER_KHRONOS_validation",
/*
// For layers included in the Android NDK.

View File

@ -2,7 +2,7 @@
#include "Common/GPU/Vulkan/VulkanFramebuffer.h"
#include "Common/GPU/Vulkan/VulkanQueueRunner.h"
static const char *rpTypeDebugNames[] = {
static const char * const rpTypeDebugNames[] = {
"RENDER",
"RENDER_DEPTH",
"MV_RENDER",

View File

@ -268,13 +268,13 @@ bool g_vulkanMayBeAvailable = false;
#define LOAD_GLOBAL_FUNC_LOCAL(lib, x) (PFN_ ## x)dlsym(lib, #x);
static const char *device_name_blacklist[] = {
static const char * const device_name_blacklist[] = {
"NVIDIA:SHIELD Tablet K1",
"SDL:Horizon",
};
#ifndef _WIN32
static const char *so_names[] = {
static const char * const so_names[] = {
#if PPSSPP_PLATFORM(IOS)
"@executable_path/Frameworks/libMoltenVK.dylib",
#elif PPSSPP_PLATFORM(MAC)

View File

@ -78,7 +78,7 @@ bool GenericLogEnabled(LogLevel level, LogType type) {
LogManager *LogManager::logManager_ = NULL;
// NOTE: Needs to be kept in sync with the LogType enum.
static const char *g_logTypeNames[] = {
static const char * const g_logTypeNames[] = {
"SYSTEM",
"BOOT",
"COMMON",

View File

@ -73,7 +73,7 @@ LoongArchCPUInfoParser::LoongArchCPUInfoParser() {
}
int LoongArchCPUInfoParser::ProcessorCount() {
static const char *marker = "core";
static const char * const marker = "core";
std::set<std::string> coreIndex;
for (auto core : cores_) {
for (auto line : core) {

View File

@ -2,11 +2,35 @@
#include "Common/StringUtils.h"
#include "Common/Net/URL.h"
const char *UrlEncoder::unreservedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~";
const char *UrlEncoder::hexChars = "0123456789ABCDEF";
int MultipartFormDataEncoder::seq = 0;
void UrlEncoder::AppendEscaped(const std::string &value)
{
static const char * const unreservedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~";
static const char * const hexChars = "0123456789ABCDEF";
for (size_t lastEnd = 0; lastEnd < value.length(); )
{
size_t pos = value.find_first_not_of(unreservedChars, lastEnd);
if (pos == value.npos)
{
data += value.substr(lastEnd);
break;
}
if (pos != lastEnd)
data += value.substr(lastEnd, pos - lastEnd);
lastEnd = pos;
// Encode the reserved character.
char c = value[pos];
data += '%';
data += hexChars[(c >> 4) & 15];
data += hexChars[(c >> 0) & 15];
++lastEnd;
}
}
void Url::Split() {
size_t colonSlashSlash = url_.find("://");
if (colonSlashSlash == std::string::npos) {

View File

@ -86,34 +86,10 @@ protected:
}
// Percent encoding, aka application/x-www-form-urlencoded.
void AppendEscaped(const std::string &value)
{
for (size_t lastEnd = 0; lastEnd < value.length(); )
{
size_t pos = value.find_first_not_of(unreservedChars, lastEnd);
if (pos == value.npos)
{
data += value.substr(lastEnd);
break;
}
if (pos != lastEnd)
data += value.substr(lastEnd, pos - lastEnd);
lastEnd = pos;
// Encode the reserved character.
char c = value[pos];
data += '%';
data += hexChars[(c >> 4) & 15];
data += hexChars[(c >> 0) & 15];
++lastEnd;
}
}
void AppendEscaped(const std::string &value);
std::string data;
int paramCount;
static const char *unreservedChars;
static const char *hexChars;
};

View File

@ -80,7 +80,7 @@ RiscVCPUInfoParser::RiscVCPUInfoParser() {
int RiscVCPUInfoParser::ProcessorCount() {
// Not using present as that counts the logical CPUs (aka harts.)
static const char *marker = "processor\t: ";
static const char * const marker = "processor\t: ";
std::set<std::string> processors;
for (auto core : cores_) {
for (auto line : core) {
@ -107,7 +107,7 @@ int RiscVCPUInfoParser::TotalLogicalCount() {
return high - low + 1;
}
static const char *marker = "hart\t\t: ";
static const char * const marker = "hart\t\t: ";
std::set<std::string> harts;
for (auto core : cores_) {
for (auto line : core) {
@ -120,7 +120,7 @@ int RiscVCPUInfoParser::TotalLogicalCount() {
}
std::string RiscVCPUInfoParser::ISAString() {
static const char *marker = "isa\t\t: ";
static const char * const marker = "isa\t\t: ";
for (auto core : cores_) {
for (auto line : core) {
if (line.find(marker) != line.npos)

View File

@ -76,9 +76,9 @@ struct ConfigPrivate {
};
#ifdef _DEBUG
static const char *logSectionName = "LogDebug";
static const char * const logSectionName = "LogDebug";
#else
static const char *logSectionName = "Log";
static const char * const logSectionName = "Log";
#endif
std::string GPUBackendToString(GPUBackend backend) {

View File

@ -1092,7 +1092,7 @@ int SavedataParam::BuildHash(unsigned char *output,
std::string SavedataParam::GetSpaceText(u64 size, bool roundUp)
{
char text[50];
static const char *suffixes[] = {"B", "KB", "MB", "GB"};
static const char * const suffixes[] = {"B", "KB", "MB", "GB"};
for (size_t i = 0; i < ARRAY_SIZE(suffixes); ++i)
{
if (size < 1024)

View File

@ -42,7 +42,7 @@
#define fseeko fseek
#endif
static const char *CACHEFILE_MAGIC = "ppssppDC";
static const char * const CACHEFILE_MAGIC = "ppssppDC";
static const s64 SAFETY_FREE_DISK_SPACE = 768 * 1024 * 1024; // 768 MB
// Aim to allow this many files cached at once.
static const u32 CACHE_SPACE_FLEX = 4;

View File

@ -737,9 +737,9 @@ static void tmFromFiletime(tm &dest, const FILETIME &src) {
// Hopefully no PSP games read directories after they create files in them...
static std::string SimulateVFATBug(std::string filename) {
// These are the characters allowed in DOS filenames.
static const char *FAT_UPPER_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&'(){}-_`~";
static const char *FAT_LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&'(){}-_`~";
static const char *LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz";
static const char * const FAT_UPPER_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&'(){}-_`~";
static const char * const FAT_LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&'(){}-_`~";
static const char * const LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz";
// To avoid logging/comparing, skip all this if it has no lowercase chars to begin with.
size_t lowerchar = filename.find_first_of(LOWER_CHARS);

View File

@ -234,7 +234,7 @@ static std::string GetGPRName(int r) {
}
void DisassembleParam(char *buf, int bufSize, u8 param, char type, u32 constant) {
static const char *vfpuCtrlNames[VFPU_CTRL_MAX] = {
static const char * const vfpuCtrlNames[VFPU_CTRL_MAX] = {
"SPFX",
"TPFX",
"DPFX",
@ -252,7 +252,7 @@ void DisassembleParam(char *buf, int bufSize, u8 param, char type, u32 constant)
"RCX6",
"RCX7",
};
static const char *initVec4Names[8] = {
static const char * const initVec4Names[8] = {
"[0 0 0 0]",
"[1 1 1 1]",
"[-1 -1 -1 -1]",
@ -261,7 +261,7 @@ void DisassembleParam(char *buf, int bufSize, u8 param, char type, u32 constant)
"[0 0 1 0]",
"[0 0 0 1]",
};
static const char *xyzw = "xyzw";
static const char * const xyzw = "xyzw";
switch (type) {
case 'G':

View File

@ -263,7 +263,7 @@ const char *MIPSDebugInterface::GetName()
}
std::string MIPSDebugInterface::GetRegName(int cat, int index) {
static const char *regName[32] = {
static const char * const regName[32] = {
"zero", "at", "v0", "v1",
"a0", "a1", "a2", "a3",
"t0", "t1", "t2", "t3",
@ -273,7 +273,7 @@ std::string MIPSDebugInterface::GetRegName(int cat, int index) {
"t8", "t9", "k0", "k1",
"gp", "sp", "fp", "ra"
};
static const char *fpRegName[32] = {
static const char * const fpRegName[32] = {
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
"f16", "f16", "f18", "f19", "f20", "f21", "f22", "f23",

View File

@ -49,7 +49,7 @@
#define MtxOff 4
inline std::string VNStr(int v, VectorSize size) {
static const char *vfpuCtrlNames[VFPU_CTRL_MAX] = {
static const char * const vfpuCtrlNames[VFPU_CTRL_MAX] = {
"SPFX",
"TPFX",
"DPFX",
@ -156,8 +156,8 @@ namespace MIPSDis
const char *name = MIPSGetName(op);
size_t outpos = snprintf(out, outSize, "%s\t[", name);
static const char *regnam[4] = {"X","Y","Z","W"};
static const char *constan[8] = {"0","1","2","1/2","3","1/3","1/4","1/6"};
static const char * const regnam[4] = {"X","Y","Z","W"};
static const char * const constan[8] = {"0","1","2","1/2","3","1/3","1/4","1/6"};
for (int i=0; i<4; i++)
{
int regnum = (data>>(i*2)) & 3;
@ -192,7 +192,7 @@ namespace MIPSDis
const char *name = MIPSGetName(op);
size_t outpos = snprintf(out, outSize, "%s\t[", name);
static const char *satNames[4] = {"", "0:1", "X", "-1:1"};
static const char * const satNames[4] = {"", "0:1", "X", "-1:1"};
for (int i=0; i<4; i++)
{
int sat = (data>>i*2)&3;
@ -228,7 +228,7 @@ namespace MIPSDis
int conNum = (op>>16) & 0x1f;
int vd = _VD;
VectorSize sz = GetVecSize(op);
static const char *constants[32] =
static const char * const constants[32] =
{
"(undef)",
"MaxFloat",

View File

@ -1064,7 +1064,7 @@ int MIPSInterpret_RunUntil(u64 globalTicks) {
const char *MIPSGetName(MIPSOpcode op)
{
static const char *noname = "unk";
static const char * const noname = "unk";
const MIPSInstruction *instr = MIPSGetInstruction(op);
if (!instr)
return noname;

View File

@ -218,7 +218,7 @@ void InitMemoryForGamePBP(FileLoader *fileLoader) {
// that probably loads a plugin and then launches the actual game. These stubs don't work in PPSSPP.
// No idea why they are doing this, but it works to just bypass it. They could stop
// inventing new filenames though...
static const char *altBootNames[] = {
static const char * const altBootNames[] = {
"disc0:/PSP_GAME/SYSDIR/EBOOT.OLD",
"disc0:/PSP_GAME/SYSDIR/EBOOT.DAT",
"disc0:/PSP_GAME/SYSDIR/EBOOT.BI",

View File

@ -57,7 +57,7 @@ enum class ReplayState {
// File data formats below.
#pragma pack(push, 1)
static const char *REPLAY_MAGIC = "PPREPLAY";
static const char * const REPLAY_MAGIC = "PPREPLAY";
static const int REPLAY_VERSION_MIN = 1;
static const int REPLAY_VERSION_CURRENT = 1;

View File

@ -64,7 +64,7 @@ void OnAchievementsLoginStateChange() {
namespace Achievements {
// It's the name of the secret, not a secret name - the value is not secret :)
static const char *RA_TOKEN_SECRET_NAME = "retroachievements";
static const char * const RA_TOKEN_SECRET_NAME = "retroachievements";
static Achievements::Statistics g_stats;

View File

@ -34,12 +34,12 @@ namespace SaveState
typedef std::function<void(Status status, const std::string &message, void *cbUserData)> Callback;
static const int NUM_SLOTS = 5;
static const char *STATE_EXTENSION = "ppst";
static const char *SCREENSHOT_EXTENSION = "jpg";
static const char *UNDO_STATE_EXTENSION = "undo.ppst";
static const char *UNDO_SCREENSHOT_EXTENSION = "undo.jpg";
static const char * const STATE_EXTENSION = "ppst";
static const char * const SCREENSHOT_EXTENSION = "jpg";
static const char * const UNDO_STATE_EXTENSION = "undo.ppst";
static const char * const UNDO_SCREENSHOT_EXTENSION = "undo.jpg";
static const char *LOAD_UNDO_NAME = "load_undo.ppst";
static const char * const LOAD_UNDO_NAME = "load_undo.ppst";
void Init();
void Shutdown();

View File

@ -76,7 +76,7 @@ void GenerateDepthDownloadVs(ShaderWriter &writer) {
writer.EndVSMain(varyings);
}
static const char *stencil_dl_fs = R"(
static const char * const stencil_dl_fs = R"(
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
@ -99,7 +99,7 @@ void main() {
}
)";
static const char *stencil_vs = R"(
static const char * const stencil_vs = R"(
#ifdef GL_ES
precision highp float;
#endif

View File

@ -1449,12 +1449,12 @@ void VertexDecoder::CompareToJit(const u8 *startPtr, u8 *decodedptr, int count,
}
}
static const char *posnames[4] = { "?", "s8", "s16", "f" };
static const char *nrmnames[4] = { "", "s8", "s16", "f" };
static const char *tcnames[4] = { "", "u8", "u16", "f" };
static const char *idxnames[4] = { "-", "u8", "u16", "?" };
static const char *weightnames[4] = { "-", "u8", "u16", "f" };
static const char *colnames[8] = { "", "?", "?", "?", "565", "5551", "4444", "8888" };
static const char * const posnames[4] = { "?", "s8", "s16", "f" };
static const char * const nrmnames[4] = { "", "s8", "s16", "f" };
static const char * const tcnames[4] = { "", "u8", "u16", "f" };
static const char * const idxnames[4] = { "-", "u8", "u16", "?" };
static const char * const weightnames[4] = { "-", "u8", "u16", "f" };
static const char * const colnames[8] = { "", "?", "?", "?", "565", "5551", "4444", "8888" };
int VertexDecoder::ToString(char *output, bool spaces) const {
char *start = output;

View File

@ -887,7 +887,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
WRITE(p, " mediump vec3 worldnormal = normalizeOr001(mul(vec4(0.0, 0.0, %s1.0, 0.0), u_world).xyz);\n", flipNormal ? "-" : "");
}
} else {
static const char *rescale[4] = {"", " * 1.9921875", " * 1.999969482421875", ""}; // 2*127.5f/128.f, 2*32767.5f/32768.f, 1.0f};
static const char * const rescale[4] = {"", " * 1.9921875", " * 1.999969482421875", ""}; // 2*127.5f/128.f, 2*32767.5f/32768.f, 1.0f};
const char *factor = rescale[boneWeightScale];
static const char * const boneWeightAttr[8] = {

View File

@ -28,7 +28,7 @@ struct Header {
uint8_t pad[3];
};
static const char *HEADER_MAGIC = "PPSSPPGE";
static const char * const HEADER_MAGIC = "PPSSPPGE";
// Version 1: Uncompressed
// Version 2: Uses snappy
// Version 3: Adds FRAMEBUF0-FRAMEBUF9

View File

@ -56,7 +56,7 @@ static const VaryingDef varyings[] = {
{ "vec2", "v_texcoord", Draw::SEM_TEXCOORD0, 0, "highp" },
};
static const char *stencil_dl_fs = R"(
static const char * const stencil_dl_fs = R"(
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
@ -79,7 +79,7 @@ void main() {
}
)";
static const char *stencil_vs = R"(
static const char * const stencil_vs = R"(
#ifdef GL_ES
precision highp float;
#endif

View File

@ -34,7 +34,7 @@ void GeDescribeVertexType(u32 op, char *buffer, int len) {
int morphCount = (op & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT;
int idx = (op & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT;
static const char *colorNames[] = {
static const char * const colorNames[] = {
NULL,
"unsupported1",
"unsupported2",
@ -44,19 +44,19 @@ void GeDescribeVertexType(u32 op, char *buffer, int len) {
"ABGR 4444",
"ABGR 8888",
};
static const char *typeNames[] = {
static const char * const typeNames[] = {
NULL,
"u8",
"u16",
"float",
};
static const char *typeNamesI[] = {
static const char * const typeNamesI[] = {
NULL,
"u8",
"u16",
"u32",
};
static const char *typeNamesS[] = {
static const char * const typeNamesS[] = {
NULL,
"s8",
"s16",
@ -474,13 +474,13 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) {
case GE_CMD_TEXMAPMODE:
{
static const char *uvgen[] = {
static const char * const uvgen[] = {
"texcoords",
"texgen matrix",
"env map",
"invalid"
};
static const char *uvproj[] = {
static const char * const uvproj[] = {
"pos",
"uv",
"normalized normal",
@ -1006,7 +1006,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) {
case GE_CMD_TEXFUNC:
{
const char *texfuncs[] = {
const char * const texfuncs[] = {
"modulate",
"decal",
"blend",
@ -1025,7 +1025,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) {
case GE_CMD_TEXFILTER:
{
static const char *textureFilters[] = {
static const char * const textureFilters[] = {
"nearest",
"linear",
"nearest, invalid",
@ -1057,7 +1057,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) {
case GE_CMD_TEXFORMAT:
{
static const char *texformats[] = {
static const char * const texformats[] = {
"5650",
"5551",
"4444",
@ -1105,7 +1105,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) {
case GE_CMD_TEXLEVEL:
{
static const char *mipLevelModes[] = {
static const char * const mipLevelModes[] = {
"auto + bias",
"bias",
"slope + bias",
@ -1149,14 +1149,14 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) {
case GE_CMD_STENCILOP:
{
static const char *stencilOps[] = { "KEEP", "ZERO", "REPLACE", "INVERT", "INCREMENT", "DECREMENT", "unsupported1", "unsupported2" };
static const char * const stencilOps[] = { "KEEP", "ZERO", "REPLACE", "INVERT", "INCREMENT", "DECREMENT", "unsupported1", "unsupported2" };
snprintf(buffer, bufsize, "Stencil op: fail=%s, pass/depthfail=%s, pass=%s", stencilOps[data & 7], stencilOps[(data >> 8) & 7], stencilOps[(data >> 16) & 7]);
}
break;
case GE_CMD_STENCILTEST:
{
static const char *zTestFuncs[] = { " NEVER ", " ALWAYS ", " == ", " != ", " < ", " <= ", " > ", " >= " };
static const char * const zTestFuncs[] = { " NEVER ", " ALWAYS ", " == ", " != ", " < ", " <= ", " > ", " >= " };
if (data & ~0xFFFF07)
snprintf(buffer, bufsize, "Stencil test: %02x%s(dst.a & %02x) (extra %06x)", (data >> 8) & 0xFF, zTestFuncs[data & 7], (data >> 16) & 0xFF, data & ~0xFFFF07);
else
@ -1170,7 +1170,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) {
case GE_CMD_ZTEST:
{
static const char *zTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" };
static const char * const zTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" };
if (data & ~7)
snprintf(buffer, bufsize, "Z test mode: %s (extra %06x)", zTestFuncs[data & 7], data & ~7);
else
@ -1202,7 +1202,7 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) {
case GE_CMD_LOGICOP:
{
const char *logicOps[] = {
const char * const logicOps[] = {
"clear",
"and",
"reverse and",

View File

@ -22,8 +22,8 @@
#import "iCadeReaderView.h"
static const char *ON_STATES = "wdxayhujikol";
static const char *OFF_STATES = "eczqtrfnmpgv";
static const char * const ON_STATES = "wdxayhujikol";
static const char * const OFF_STATES = "eczqtrfnmpgv";
@interface iCadeReaderView()