# HG changeset patch # User nemo # Date 1286393876 14400 # Node ID 9a4bbc1f67a24dbacebcf44b6cdeb7b1a906f52d # Parent 6f4d3c7fa8be94ad9c85b3b0b424fbf27a8ef129 Inline most of uFloat (saves ~7.5% opcount on a test game), inline a few very short candidates in uMisc, comment out some unused functions in uMisc diff -r 6f4d3c7fa8be -r 9a4bbc1f67a2 hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Wed Oct 06 14:40:32 2010 -0400 +++ b/hedgewars/uFloat.pas Wed Oct 06 15:37:56 2010 -0400 @@ -22,7 +22,6 @@ interface {$IFDEF FPC} -{$INLINE ON} {$IFDEF ENDIAN_LITTLE} type hwFloat = record isNegative: boolean; @@ -43,26 +42,26 @@ operator + (const z1, z2: hwFloat) z : hwFloat; inline; operator - (const z1, z2: hwFloat) z : hwFloat; inline; -operator - (const z1: hwFloat) z : hwFloat; +operator - (const z1: hwFloat) z : hwFloat; inline; -operator * (const z1, z2: hwFloat) z : hwFloat; +operator * (const z1, z2: hwFloat) z : hwFloat; inline; operator * (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline; -operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; -operator / (const z1: hwFloat; const z2: LongInt) z : hwFloat; +operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; inline; +operator / (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline; -operator < (const z1, z2: hwFloat) b : boolean; -operator > (const z1, z2: hwFloat) b : boolean; +operator < (const z1, z2: hwFloat) b : boolean; inline; +operator > (const z1, z2: hwFloat) b : boolean; inline; function cstr(const z: hwFloat): shortstring; -function hwRound(const t: hwFloat): LongInt; -function hwAbs(const t: hwFloat): hwFloat; +function hwRound(const t: hwFloat): LongInt; inline; +function hwAbs(const t: hwFloat): hwFloat; inline; function hwSqr(const t: hwFloat): hwFloat; inline; function hwSqrt(const t: hwFloat): hwFloat; inline; function Distance(const dx, dy: hwFloat): hwFloat; function DistanceI(const dx, dy: LongInt): hwFloat; function AngleSin(const Angle: Longword): hwFloat; function AngleCos(const Angle: Longword): hwFloat; -function SignAs(const num, signum: hwFloat): hwFloat; +function SignAs(const num, signum: hwFloat): hwFloat; inline; {$IFDEF FPC} {$J-} @@ -148,7 +147,7 @@ {$ENDIF} implementation -uses uMisc; +//uses uMisc; {$IFDEF FPC} @@ -348,7 +347,7 @@ function AngleSin(const Angle: Longword): hwFloat; begin {$IFDEF DEBUGFILE} -TryDo((Angle >= 0) and (Angle <= 2048), 'Sin param exceeds limits', true); +//TryDo((Angle >= 0) and (Angle <= 2048), 'Sin param exceeds limits', true); {$ENDIF} AngleSin.isNegative:= false; if Angle < 1024 then AngleSin.QWordValue:= SinTable[Angle] @@ -358,7 +357,7 @@ function AngleCos(const Angle: Longword): hwFloat; begin {$IFDEF DEBUGFILE} -TryDo((Angle >= 0) and (Angle <= 2048), 'Cos param exceeds limits', true); +//TryDo((Angle >= 0) and (Angle <= 2048), 'Cos param exceeds limits', true); {$ENDIF} AngleCos.isNegative:= Angle > 1024; if Angle < 1024 then AngleCos.QWordValue:= SinTable[1024 - Angle] diff -r 6f4d3c7fa8be -r 9a4bbc1f67a2 hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Wed Oct 06 14:40:32 2010 -0400 +++ b/hedgewars/uMisc.pas Wed Oct 06 15:37:56 2010 -0400 @@ -17,7 +17,6 @@ *) {$INCLUDE "options.inc"} -{$INLINE ON} unit uMisc; interface @@ -165,9 +164,9 @@ function EnumToStr(const en : TAmmoType) : shortstring; overload; function EnumToStr(const en : THogEffect) : shortstring; overload; procedure movecursor(dx, dy: LongInt); -function hwSign(r: hwFloat): LongInt; -function Min(a, b: LongInt): LongInt; -function Max(a, b: LongInt): LongInt; +function hwSign(r: hwFloat): LongInt; inline; +function Min(a, b: LongInt): LongInt; inline; +function Max(a, b: LongInt): LongInt; inline; procedure OutError(Msg: shortstring; isFatalError: boolean); procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline; procedure SDLTry(Assert: boolean; isFatal: boolean); @@ -176,8 +175,10 @@ function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt; function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt; +(* procedure AdjustColor(var Color: Longword); procedure SetKB(n: Longword); +*) procedure SendKB; procedure SetLittle(var r: hwFloat); procedure SendStat(sit: TStatInfoType; s: shortstring); @@ -191,7 +192,7 @@ function endian(independent: LongWord): LongWord; {$IFDEF DEBUGFILE} procedure AddFileLog(s: shortstring); -function RectToStr(Rect: TSDL_Rect): shortstring; +(* function RectToStr(Rect: TSDL_Rect): shortstring; *) {$ENDIF} procedure MakeScreenshot(filename: shortstring); @@ -298,11 +299,19 @@ if not Assert then OutError(SDL_GetError, isFatal) end; +(* procedure AdjustColor(var Color: Longword); begin Color:= SDL_MapRGB(PixelFormat, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF) end; +procedure SetKB(n: Longword); +begin +KBnum:= n +end; +*) + + function IntToStr(n: LongInt): shortstring; begin str(n, IntToStr) @@ -356,11 +365,6 @@ DxDy2AttackAngle:= trunc(arctan2(dY, dX) * MaxAngleDivPI) end; -procedure SetKB(n: Longword); -begin -KBnum:= n -end; - procedure SendKB; var s: shortstring; begin @@ -657,11 +661,12 @@ writeln(f, GameTicks: 6, ': ', s); flush(f) end; - +(* function RectToStr(Rect: TSDL_Rect): shortstring; begin RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')' end; +*) {$ENDIF} function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;