Skip to content

Commit

Permalink
Codechange: replace static inline with static for non-class functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rubidium42 committed Jan 6, 2024
1 parent 06a5fa6 commit 3a676a5
Show file tree
Hide file tree
Showing 87 changed files with 697 additions and 697 deletions.
4 changes: 2 additions & 2 deletions src/3rdparty/squirrel/include/squirrel.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
static inline void sq_pushstring(HSQUIRRELVM v, const std::string &str, SQInteger len = -1) { sq_pushstring(v, str.data(), len == -1 ? str.size() : len); }
inline void sq_pushstring(HSQUIRRELVM v, const std::string &str, SQInteger len = -1) { sq_pushstring(v, str.data(), len == -1 ? str.size() : len); }
void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
void sq_pushbool(HSQUIRRELVM v,SQBool b);
Expand Down Expand Up @@ -308,7 +308,7 @@ SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);
const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);
const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err, SQInteger len = -1);
static inline SQRESULT sq_throwerror(HSQUIRRELVM v, const std::string_view err) { return sq_throwerror(v, err.data(), err.size()); }
inline SQRESULT sq_throwerror(HSQUIRRELVM v, const std::string_view err) { return sq_throwerror(v, err.data(), err.size()); }
void sq_reseterror(HSQUIRRELVM v);
void sq_getlasterror(HSQUIRRELVM v);

Expand Down
12 changes: 6 additions & 6 deletions src/autoreplace_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, Group
* Remove all engine replacement settings for the given company.
* @param c the company.
*/
static inline void RemoveAllEngineReplacementForCompany(Company *c)
inline void RemoveAllEngineReplacementForCompany(Company *c)
{
RemoveAllEngineReplacement(&c->engine_renew_list);
}
Expand All @@ -36,7 +36,7 @@ static inline void RemoveAllEngineReplacementForCompany(Company *c)
* @return The engine type to replace with, or INVALID_ENGINE if no
* replacement is in the list.
*/
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = nullptr)
inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = nullptr)
{
return EngineReplacement(c->engine_renew_list, engine, group, replace_when_old);
}
Expand All @@ -48,7 +48,7 @@ static inline EngineID EngineReplacementForCompany(const Company *c, EngineID en
* @param group The group related to this replacement.
* @return true if a replacement was set up, false otherwise.
*/
static inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
{
return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
}
Expand All @@ -60,7 +60,7 @@ static inline bool EngineHasReplacementForCompany(const Company *c, EngineID eng
* @param group The group related to this replacement.
* @return True if a replacement when old was set up, false otherwise.
*/
static inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
{
bool replace_when_old;
EngineReplacement(c->engine_renew_list, engine, group, &replace_when_old);
Expand All @@ -77,7 +77,7 @@ static inline bool EngineHasReplacementWhenOldForCompany(const Company *c, Engin
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
{
return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, replace_when_old, flags);
}
Expand All @@ -90,7 +90,7 @@ static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID ol
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
static inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
{
return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
}
Expand Down
4 changes: 2 additions & 2 deletions src/autoslope.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @param entrance Entrance edge.
* @return true iff terraforming is allowed.
*/
static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
{
if (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new)) return false;
return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
Expand All @@ -41,7 +41,7 @@ static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slop
*
* @return true iff autoslope is enabled.
*/
static inline bool AutoslopeEnabled()
inline bool AutoslopeEnabled()
{
return (_settings_game.construction.autoslope &&
(_current_company < MAX_COMPANIES ||
Expand Down
18 changes: 9 additions & 9 deletions src/blitter/32bpp_sse_func.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifdef WITH_SSE

GNU_TARGET(SSE_TARGET)
static inline void InsertFirstUint32(const uint32_t value, __m128i &into)
inline void InsertFirstUint32(const uint32_t value, __m128i &into)
{
#if (SSE_VERSION >= 4)
into = _mm_insert_epi32(into, value, 0);
Expand All @@ -24,7 +24,7 @@ static inline void InsertFirstUint32(const uint32_t value, __m128i &into)
}

GNU_TARGET(SSE_TARGET)
static inline void InsertSecondUint32(const uint32_t value, __m128i &into)
inline void InsertSecondUint32(const uint32_t value, __m128i &into)
{
#if (SSE_VERSION >= 4)
into = _mm_insert_epi32(into, value, 1);
Expand All @@ -35,7 +35,7 @@ static inline void InsertSecondUint32(const uint32_t value, __m128i &into)
}

GNU_TARGET(SSE_TARGET)
static inline void LoadUint64(const uint64_t value, __m128i &into)
inline void LoadUint64(const uint64_t value, __m128i &into)
{
#ifdef POINTER_IS_64BIT
into = _mm_cvtsi64_si128(value);
Expand All @@ -50,7 +50,7 @@ static inline void LoadUint64(const uint64_t value, __m128i &into)
}

GNU_TARGET(SSE_TARGET)
static inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
{
#if (SSE_VERSION == 2)
from = _mm_and_si128(from, mask); // PAND, wipe high bytes to keep low bytes when packing
Expand All @@ -61,7 +61,7 @@ static inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
}

GNU_TARGET(SSE_TARGET)
static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
{
#if (SSE_VERSION == 2)
__m128i alphaAB = _mm_shufflelo_epi16(from, 0x3F); // PSHUFLW, put alpha1 in front of each rgb1
Expand All @@ -73,7 +73,7 @@ static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
}

GNU_TARGET(SSE_TARGET)
static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
{
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8_t into uint16
__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
Expand All @@ -97,7 +97,7 @@ static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128
* rgb = rgb * ((256/4) * 4 - (alpha/4)) / ((256/4) * 4)
*/
GNU_TARGET(SSE_TARGET)
static inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
{
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());
__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
Expand Down Expand Up @@ -145,7 +145,7 @@ IGNORE_UNINITIALIZED_WARNING_STOP
/** ReallyAdjustBrightness() is not called that often.
* Inlining this function implies a far jump, which has a huge latency.
*/
static inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
{
/* Shortcut for normal brightness. */
if (brightness == Blitter_32bppBase::DEFAULT_BRIGHTNESS) return colour;
Expand All @@ -154,7 +154,7 @@ static inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
}

GNU_TARGET(SSE_TARGET)
static inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
{
#if (SSE_VERSION < 3)
NOT_REACHED();
Expand Down
2 changes: 1 addition & 1 deletion src/bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool HasBridgeFlatRamp(Slope tileh, Axis axis);
* @param i The type of bridge to get the specification for.
* @return The specification.
*/
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
inline const BridgeSpec *GetBridgeSpec(BridgeType i)
{
assert(i < lengthof(_bridge));
return &_bridge[i];
Expand Down
26 changes: 13 additions & 13 deletions src/bridge_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @pre IsTileType(t, MP_TUNNELBRIDGE)
* @return true if the structure is a bridge one
*/
static inline bool IsBridge(Tile t)
inline bool IsBridge(Tile t)
{
assert(IsTileType(t, MP_TUNNELBRIDGE));
return HasBit(t.m5(), 7);
Expand All @@ -32,7 +32,7 @@ static inline bool IsBridge(Tile t)
* @param t The tile to analyze
* @return true if a bridge is present
*/
static inline bool IsBridgeTile(Tile t)
inline bool IsBridgeTile(Tile t)
{
return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
}
Expand All @@ -42,7 +42,7 @@ static inline bool IsBridgeTile(Tile t)
* @param t The tile to analyze
* @return true if a bridge is detected above
*/
static inline bool IsBridgeAbove(Tile t)
inline bool IsBridgeAbove(Tile t)
{
return GB(t.type(), 2, 2) != 0;
}
Expand All @@ -53,7 +53,7 @@ static inline bool IsBridgeAbove(Tile t)
* @pre IsBridgeTile(t)
* @return The bridge type
*/
static inline BridgeType GetBridgeType(Tile t)
inline BridgeType GetBridgeType(Tile t)
{
assert(IsBridgeTile(t));
return GB(t.m6(), 2, 4);
Expand All @@ -65,7 +65,7 @@ static inline BridgeType GetBridgeType(Tile t)
* @pre IsBridgeAbove(t)
* @return the above mentioned axis
*/
static inline Axis GetBridgeAxis(Tile t)
inline Axis GetBridgeAxis(Tile t)
{
assert(IsBridgeAbove(t));
return (Axis)(GB(t.type(), 2, 2) - 1);
Expand All @@ -81,7 +81,7 @@ int GetBridgeHeight(TileIndex tile);
* @param tile the bridge ramp tile to get the bridge height from
* @return the height of the bridge in pixels
*/
static inline int GetBridgePixelHeight(TileIndex tile)
inline int GetBridgePixelHeight(TileIndex tile)
{
return GetBridgeHeight(tile) * TILE_HEIGHT;
}
Expand All @@ -91,7 +91,7 @@ static inline int GetBridgePixelHeight(TileIndex tile)
* @param t the tile to remove the bridge from
* @param a the axis of the bridge to remove
*/
static inline void ClearSingleBridgeMiddle(Tile t, Axis a)
inline void ClearSingleBridgeMiddle(Tile t, Axis a)
{
ClrBit(t.type(), 2 + a);
}
Expand All @@ -100,7 +100,7 @@ static inline void ClearSingleBridgeMiddle(Tile t, Axis a)
* Removes bridges from the given, that is bridges along the X and Y axis.
* @param t the tile to remove the bridge from
*/
static inline void ClearBridgeMiddle(Tile t)
inline void ClearBridgeMiddle(Tile t)
{
ClearSingleBridgeMiddle(t, AXIS_X);
ClearSingleBridgeMiddle(t, AXIS_Y);
Expand All @@ -111,7 +111,7 @@ static inline void ClearBridgeMiddle(Tile t)
* @param t the tile to add the bridge to
* @param a the axis of the bridge to add
*/
static inline void SetBridgeMiddle(Tile t, Axis a)
inline void SetBridgeMiddle(Tile t, Axis a)
{
SetBit(t.type(), 2 + a);
}
Expand All @@ -125,7 +125,7 @@ static inline void SetBridgeMiddle(Tile t, Axis a)
* @param tt the transport type of the bridge
* @note this function should not be called directly.
*/
static inline void MakeBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt)
inline void MakeBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt)
{
SetTileType(t, MP_TUNNELBRIDGE);
SetTileOwner(t, o);
Expand All @@ -150,7 +150,7 @@ static inline void MakeBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDi
* @param road_rt the road type of the bridge
* @param tram_rt the tram type of the bridge
*/
static inline void MakeRoadBridgeRamp(Tile t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadType road_rt, RoadType tram_rt)
inline void MakeRoadBridgeRamp(Tile t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadType road_rt, RoadType tram_rt)
{
MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD);
SetRoadOwner(t, RTT_ROAD, owner_road);
Expand All @@ -166,7 +166,7 @@ static inline void MakeRoadBridgeRamp(Tile t, Owner o, Owner owner_road, Owner o
* @param d the direction this ramp must be facing
* @param rt the rail type of the bridge
*/
static inline void MakeRailBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt)
inline void MakeRailBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt)
{
MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL);
SetRailType(t, rt);
Expand All @@ -178,7 +178,7 @@ static inline void MakeRailBridgeRamp(Tile t, Owner o, BridgeType bridgetype, Di
* @param o the new owner of the bridge ramp
* @param d the direction this ramp must be facing
*/
static inline void MakeAqueductBridgeRamp(Tile t, Owner o, DiagDirection d)
inline void MakeAqueductBridgeRamp(Tile t, Owner o, DiagDirection d)
{
MakeBridgeRamp(t, o, 0, d, TRANSPORT_WATER);
}
Expand Down
14 changes: 7 additions & 7 deletions src/cargomonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static_assert(MAX_COMPANIES <= (1 << CCB_COMPANY_LENGTH));
* @param ind %Industry providing or accepting the cargo.
* @return The encoded cargo/company/industry number.
*/
static inline CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, CargoID ctype, IndustryID ind)
inline CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, CargoID ctype, IndustryID ind)
{
assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH));
assert(company < (1 << CCB_COMPANY_LENGTH));
Expand All @@ -78,7 +78,7 @@ static inline CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, Cargo
* @param town %Town providing or accepting the cargo.
* @return The encoded cargo/company/town number.
*/
static inline CargoMonitorID EncodeCargoTownMonitor(CompanyID company, CargoID ctype, TownID town)
inline CargoMonitorID EncodeCargoTownMonitor(CompanyID company, CargoID ctype, TownID town)
{
assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH));
assert(company < (1 << CCB_COMPANY_LENGTH));
Expand All @@ -95,7 +95,7 @@ static inline CargoMonitorID EncodeCargoTownMonitor(CompanyID company, CargoID c
* @param num Cargo monitoring number to decode.
* @return The extracted company id.
*/
static inline CompanyID DecodeMonitorCompany(CargoMonitorID num)
inline CompanyID DecodeMonitorCompany(CargoMonitorID num)
{
return static_cast<CompanyID>(GB(num, CCB_COMPANY_START, CCB_COMPANY_LENGTH));
}
Expand All @@ -105,7 +105,7 @@ static inline CompanyID DecodeMonitorCompany(CargoMonitorID num)
* @param num Cargo monitoring number to decode.
* @return The extracted cargo type.
*/
static inline CargoID DecodeMonitorCargoType(CargoMonitorID num)
inline CargoID DecodeMonitorCargoType(CargoMonitorID num)
{
return GB(num, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH);
}
Expand All @@ -115,7 +115,7 @@ static inline CargoID DecodeMonitorCargoType(CargoMonitorID num)
* @param num Cargo monitoring number to decode.
* @return true if monitoring an industry, false if monitoring a town.
*/
static inline bool MonitorMonitorsIndustry(CargoMonitorID num)
inline bool MonitorMonitorsIndustry(CargoMonitorID num)
{
return HasBit(num, CCB_IS_INDUSTRY_BIT);
}
Expand All @@ -125,7 +125,7 @@ static inline bool MonitorMonitorsIndustry(CargoMonitorID num)
* @param num Cargo monitoring number to decode.
* @return The extracted industry id, or #INVALID_INDUSTRY if the number does not monitor an industry.
*/
static inline IndustryID DecodeMonitorIndustry(CargoMonitorID num)
inline IndustryID DecodeMonitorIndustry(CargoMonitorID num)
{
if (!MonitorMonitorsIndustry(num)) return INVALID_INDUSTRY;
return GB(num, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH);
Expand All @@ -136,7 +136,7 @@ static inline IndustryID DecodeMonitorIndustry(CargoMonitorID num)
* @param num Cargo monitoring number to decode.
* @return The extracted town id, or #INVALID_TOWN if the number does not monitor a town.
*/
static inline TownID DecodeMonitorTown(CargoMonitorID num)
inline TownID DecodeMonitorTown(CargoMonitorID num)
{
if (MonitorMonitorsIndustry(num)) return INVALID_TOWN;
return GB(num, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH);
Expand Down
2 changes: 1 addition & 1 deletion src/cargotype.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ extern span<const CargoSpec *> _sorted_standard_cargo_specs;
* @param cc Cargo class.
* @return The type fits in the class.
*/
static inline bool IsCargoInClass(CargoID c, CargoClass cc)
inline bool IsCargoInClass(CargoID c, CargoClass cc)
{
return (CargoSpec::Get(c)->classes & cc) != 0;
}
Expand Down
Loading

0 comments on commit 3a676a5

Please sign in to comment.