use inline out

This commit is contained in:
adelikat 2020-02-25 13:15:43 -06:00
parent f873e7f9c3
commit 72d4b0ac46
20 changed files with 39 additions and 77 deletions

View File

@ -876,8 +876,7 @@ namespace BizHawk.Client.EmuHawk
} }
// (TODO - inefficient- build directly in a buffer) // (TODO - inefficient- build directly in a buffer)
int bytes_written; AVIWriterImports.AVIStreamWrite(pAviRawAudioStream, outStatus.audio_samples, todo_realsamples, buf, todo_realsamples * 4, 0, IntPtr.Zero, out var bytes_written);
AVIWriterImports.AVIStreamWrite(pAviRawAudioStream, outStatus.audio_samples, todo_realsamples, buf, todo_realsamples * 4, 0, IntPtr.Zero, out bytes_written);
outStatus.audio_samples += todo_realsamples; outStatus.audio_samples += todo_realsamples;
outStatus.audio_bytes += bytes_written; outStatus.audio_bytes += bytes_written;
outStatus.audio_buffered_shorts = 0; outStatus.audio_buffered_shorts = 0;
@ -925,8 +924,7 @@ namespace BizHawk.Client.EmuHawk
bp += pitch_add; bp += pitch_add;
} }
int bytes_written; int ret = AVIWriterImports.AVIStreamWrite(pAviCompressedVideoStream, outStatus.video_frames, 1, new IntPtr(bytes_ptr), todo, AVIIF_KEYFRAME, IntPtr.Zero, out var bytes_written);
int ret = AVIWriterImports.AVIStreamWrite(pAviCompressedVideoStream, outStatus.video_frames, 1, new IntPtr(bytes_ptr), todo, AVIIF_KEYFRAME, IntPtr.Zero, out bytes_written);
outStatus.video_bytes += bytes_written; outStatus.video_bytes += bytes_written;
outStatus.video_frames++; outStatus.video_frames++;
} }
@ -957,8 +955,7 @@ namespace BizHawk.Client.EmuHawk
idx -= w * 2; idx -= w * 2;
} }
int bytes_written; int ret = AVIWriterImports.AVIStreamWrite(pAviCompressedVideoStream, outStatus.video_frames, 1, new IntPtr(bytes_ptr), todo * 3, AVIIF_KEYFRAME, IntPtr.Zero, out var bytes_written);
int ret = AVIWriterImports.AVIStreamWrite(pAviCompressedVideoStream, outStatus.video_frames, 1, new IntPtr(bytes_ptr), todo * 3, AVIIF_KEYFRAME, IntPtr.Zero, out bytes_written);
outStatus.video_bytes += bytes_written; outStatus.video_bytes += bytes_written;
outStatus.video_frames++; outStatus.video_frames++;
} }

View File

@ -47,7 +47,7 @@ namespace BizHawk.Client.EmuHawk
//NOTE: this throws EGL exceptions anyway. I'm going to ignore it and whine about it later //NOTE: this throws EGL exceptions anyway. I'm going to ignore it and whine about it later
} }
public string API { get { return "OPENGL"; } } public string API => "OPENGL";
public int Version public int Version
{ {
@ -252,9 +252,8 @@ namespace BizHawk.Client.EmuHawk
if (required) if (required)
throw new InvalidOperationException($"Error creating pipeline (error returned from glLinkProgram): {errcode}\r\n\r\n{resultLog}"); throw new InvalidOperationException($"Error creating pipeline (error returned from glLinkProgram): {errcode}\r\n\r\n{resultLog}");
else success = false; else success = false;
int linkStatus; GL.GetProgram(pid, GetProgramParameterName.LinkStatus, out var linkStatus);
GL.GetProgram(pid, GetProgramParameterName.LinkStatus, out linkStatus);
if (linkStatus == 0) if (linkStatus == 0)
if (required) if (required)
throw new InvalidOperationException($"Error creating pipeline (link status false returned from glLinkProgram): \r\n\r\n{resultLog}"); throw new InvalidOperationException($"Error creating pipeline (link status false returned from glLinkProgram): \r\n\r\n{resultLog}");
@ -286,8 +285,7 @@ namespace BizHawk.Client.EmuHawk
//get all the attributes (not needed) //get all the attributes (not needed)
List<AttributeInfo> attributes = new List<AttributeInfo>(); List<AttributeInfo> attributes = new List<AttributeInfo>();
int nAttributes; GL.GetProgram(pid, GetProgramParameterName.ActiveAttributes, out var nAttributes);
GL.GetProgram(pid, GetProgramParameterName.ActiveAttributes, out nAttributes);
for (int i = 0; i < nAttributes; i++) for (int i = 0; i < nAttributes; i++)
{ {
int size, length; int size, length;
@ -299,16 +297,14 @@ namespace BizHawk.Client.EmuHawk
//get all the uniforms //get all the uniforms
List<UniformInfo> uniforms = new List<UniformInfo>(); List<UniformInfo> uniforms = new List<UniformInfo>();
int nUniforms; GL.GetProgram(pid,GetProgramParameterName.ActiveUniforms,out var nUniforms);
GL.GetProgram(pid,GetProgramParameterName.ActiveUniforms,out nUniforms);
List<int> samplers = new List<int>(); List<int> samplers = new List<int>();
for (int i = 0; i < nUniforms; i++) for (int i = 0; i < nUniforms; i++)
{ {
int size, length; int size, length;
ActiveUniformType type;
string name = new System.Text.StringBuilder(1024).ToString(); string name = new System.Text.StringBuilder(1024).ToString();
GL.GetActiveUniform(pid, i, 1024, out length, out size, out type, out name); GL.GetActiveUniform(pid, i, 1024, out length, out size, out var type, out name);
errcode = GL.GetError(); errcode = GL.GetError();
int loc = GL.GetUniformLocation(pid, name); int loc = GL.GetUniformLocation(pid, name);
@ -758,8 +754,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
int n; GL.GetShader(sid, ShaderParameter.CompileStatus, out var n);
GL.GetShader(sid, ShaderParameter.CompileStatus, out n);
if (n == 0) if (n == 0)
if (required) if (required)

View File

@ -129,8 +129,7 @@ namespace BizHawk.Client.EmuHawk
private int GetSource(ALGetSourcei param) private int GetSource(ALGetSourcei param)
{ {
int value; AL.GetSource(_sourceID, param, out var value);
AL.GetSource(_sourceID, param, out value);
return value; return value;
} }

View File

@ -210,14 +210,11 @@ namespace BizHawk.Client.EmuHawk
private void GetSamplesFromBase(ref double scaleFactor) private void GetSamplesFromBase(ref double scaleFactor)
{ {
short[] samples;
int count;
if (BaseSoundProvider.SyncMode != SyncSoundMode.Sync) if (BaseSoundProvider.SyncMode != SyncSoundMode.Sync)
{ {
throw new InvalidOperationException("Base sound provider must be in sync mode."); throw new InvalidOperationException("Base sound provider must be in sync mode.");
} }
BaseSoundProvider.GetSamplesSync(out samples, out count); BaseSoundProvider.GetSamplesSync(out var samples, out var count);
bool correctedEmptyFrame = false; bool correctedEmptyFrame = false;
if (count == 0) if (count == 0)

View File

@ -113,8 +113,7 @@ namespace BizHawk.Client.EmuHawk
ulong version = 0; ulong version = 0;
for (int i = 0; i < split.Length; i++) for (int i = 0; i < split.Length; i++)
{ {
ushort versionPart; if (!UInt16.TryParse(split[i], out var versionPart)) return 0;
if (!UInt16.TryParse(split[i], out versionPart)) return 0;
version |= (ulong)versionPart << (48 - (i * 16)); version |= (ulong)versionPart << (48 - (i * 16));
} }
return version; return version;

View File

@ -56,8 +56,7 @@ namespace BizHawk.Client.EmuHawk
uint a = _currentDisassemblerAddress; uint a = _currentDisassemblerAddress;
for (int i = 0; i <= lineCount; ++i) for (int i = 0; i <= lineCount; ++i)
{ {
int advance; string line = Disassembler.Disassemble(MemoryDomains.SystemBus, a, out var advance);
string line = Disassembler.Disassemble(MemoryDomains.SystemBus, a, out advance);
_disassemblyLines.Add(new DisasmOp(a, advance, line)); _disassemblyLines.Add(new DisasmOp(a, advance, line));
a += (uint)advance; a += (uint)advance;
if (a > BusMaxValue) if (a > BusMaxValue)
@ -107,8 +106,7 @@ namespace BizHawk.Client.EmuHawk
while (true) while (true)
{ {
int bytestoadvance; Disassembler.Disassemble(MemoryDomains.SystemBus, newaddress, out var bytestoadvance);
Disassembler.Disassemble(MemoryDomains.SystemBus, newaddress, out bytestoadvance);
if (newaddress + bytestoadvance == _currentDisassemblerAddress) if (newaddress + bytestoadvance == _currentDisassemblerAddress)
{ {
break; break;

View File

@ -2474,8 +2474,7 @@ namespace BizHawk.Client.EmuHawk
foreach (var t in code) foreach (var t in code)
{ {
hexcode <<= 5; hexcode <<= 5;
long y; _GENgameGenieTable.TryGetValue(t, out var y);
_GENgameGenieTable.TryGetValue(t, out y);
hexcode |= y; hexcode |= y;
} }
long decoded = (hexcode & 0xFF00000000) >> 32; long decoded = (hexcode & 0xFF00000000) >> 32;

View File

@ -1182,8 +1182,7 @@ namespace BizHawk.Client.EmuHawk
private void paletteViewer_MouseMove(object sender, MouseEventArgs e) private void paletteViewer_MouseMove(object sender, MouseEventArgs e)
{ {
Point pt; bool valid = TranslatePaletteCoord(e.Location, out var pt);
bool valid = TranslatePaletteCoord(e.Location, out pt);
if (!valid) return; if (!valid) return;
lastColorNum = pt.Y * 16 + pt.X; lastColorNum = pt.Y * 16 + pt.X;
UpdateColorDetails(); UpdateColorDetails();

View File

@ -335,8 +335,7 @@ namespace BizHawk.Common
return false; return false;
} }
var tkp = new TOKEN_PRIVILEGES { PrivilegeCount = 1, Privileges = new LUID_AND_ATTRIBUTES[1] }; var tkp = new TOKEN_PRIVILEGES { PrivilegeCount = 1, Privileges = new LUID_AND_ATTRIBUTES[1] };
LUID luid; if (!LookupPrivilegeValue(null, PrivilegeName, out var luid))
if (!LookupPrivilegeValue(null, PrivilegeName, out luid))
{ {
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
return false; return false;

View File

@ -128,8 +128,7 @@ namespace BizHawk.Common
{ {
il.Emit(OpCodes.Ldloc, target); il.Emit(OpCodes.Ldloc, target);
il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Ldarg_1);
MethodInfo m; if (!Readhandlers.TryGetValue(field.FieldType, out var m))
if (!Readhandlers.TryGetValue(field.FieldType, out m))
{ {
throw new InvalidOperationException($"(R) Can't handle nested type {field.FieldType}"); throw new InvalidOperationException($"(R) Can't handle nested type {field.FieldType}");
} }
@ -153,8 +152,7 @@ namespace BizHawk.Common
il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Ldarg_1);
il.Emit(OpCodes.Ldloc, target); il.Emit(OpCodes.Ldloc, target);
il.Emit(OpCodes.Ldfld, field); il.Emit(OpCodes.Ldfld, field);
MethodInfo m; if (!Writehandlers.TryGetValue(field.FieldType, out var m))
if (!Writehandlers.TryGetValue(field.FieldType, out m))
{ {
throw new InvalidOperationException($"(W) Can't handle nested type {field.FieldType}"); throw new InvalidOperationException($"(W) Can't handle nested type {field.FieldType}");
} }
@ -180,8 +178,7 @@ namespace BizHawk.Common
private static SerializationFactory GetFactory(Type t) private static SerializationFactory GetFactory(Type t)
{ {
SerializationFactory f; if (!Serializers.TryGetValue(t, out var f))
if (!Serializers.TryGetValue(t, out f))
{ {
f = CreateFactory(t); f = CreateFactory(t);
Serializers[t] = f; Serializers[t] = f;

View File

@ -26,8 +26,7 @@ namespace BizHawk.Common
/// <param name="obj">the obj to act on</param> /// <param name="obj">the obj to act on</param>
public static void SetDefaultValues<T>(T obj) public static void SetDefaultValues<T>(T obj)
{ {
DefaultValueSetter f; if (!DefaultValueSetters.TryGetValue(typeof(T), out var f))
if (!DefaultValueSetters.TryGetValue(typeof(T), out f))
{ {
f = CreateSetter(typeof(T)); f = CreateSetter(typeof(T));
DefaultValueSetters[typeof(T)] = f; DefaultValueSetters[typeof(T)] = f;

View File

@ -37,10 +37,8 @@ namespace BizHawk.Emulation.Common
public void GetSamplesAsync(short[] samples) public void GetSamplesAsync(short[] samples)
{ {
short[] sampin; _input.GetSamplesSync(out var sampIn, out var numSamp);
int numsamp; _buffer.EnqueueSamples(sampIn, numSamp);
_input.GetSamplesSync(out sampin, out numsamp);
_buffer.EnqueueSamples(sampin, numsamp);
_buffer.OutputSamples(samples, samples.Length / 2); _buffer.OutputSamples(samples, samples.Length / 2);
} }

View File

@ -425,9 +425,7 @@ namespace BizHawk.Emulation.Common
{ {
if (_input != null) if (_input != null)
{ {
short[] sampin; _input.GetSamplesSync(out var sampin, out int nsampin);
int nsampin;
_input.GetSamplesSync(out sampin, out nsampin);
EnqueueSamples(sampin, nsampin); EnqueueSamples(sampin, nsampin);
} }

View File

@ -171,8 +171,7 @@ namespace BizHawk.Emulation.DiscSystem
/// <exception cref="CCDParseException"><paramref name="key"/> not found in <see langword="this"/></exception> /// <exception cref="CCDParseException"><paramref name="key"/> not found in <see langword="this"/></exception>
public int FetchOrFail(string key) public int FetchOrFail(string key)
{ {
int ret; if(!TryGetValue(key, out var ret))
if(!TryGetValue(key, out ret))
throw new CCDParseException($"Malformed or unexpected CCD format: missing required [Entry] key: {key}"); throw new CCDParseException($"Malformed or unexpected CCD format: missing required [Entry] key: {key}");
return ret; return ret;
} }

View File

@ -250,8 +250,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
break; break;
} }
string strindexnum = clp.ReadToken(); string strindexnum = clp.ReadToken();
int indexnum; if (!int.TryParse(strindexnum, out var indexnum) || indexnum < 0 || indexnum > 99)
if (!int.TryParse(strindexnum, out indexnum) || indexnum < 0 || indexnum > 99)
{ {
job.Error($"Invalid INDEX number: {strindexnum}"); job.Error($"Invalid INDEX number: {strindexnum}");
break; break;
@ -331,15 +330,15 @@ namespace BizHawk.Emulation.DiscSystem.CUE
job.Error("Incomplete TRACK command"); job.Error("Incomplete TRACK command");
break; break;
} }
string str_tracknum = clp.ReadToken(); string str_tracknum = clp.ReadToken();
int tracknum; if (!int.TryParse(str_tracknum, out int tracknum) || tracknum < 1 || tracknum > 99)
if (!int.TryParse(str_tracknum, out tracknum) || tracknum < 1 || tracknum > 99)
{ {
job.Error($"Invalid TRACK number: {str_tracknum}"); job.Error($"Invalid TRACK number: {str_tracknum}");
break; break;
} }
//TODO - check sequentiality? maybe as a warning // TODO - check sequentiality? maybe as a warning
CueTrackType tt; CueTrackType tt;
var str_trackType = clp.ReadToken(); var str_trackType = clp.ReadToken();

View File

@ -504,15 +504,13 @@ namespace BizHawk.Emulation.DiscSystem
foreach (var s in aSessions.Values) foreach (var s in aSessions.Values)
{ {
Session session = new Session(); Session session = new Session();
ATrack startTrack;
ATrack endTrack;
if (!aTracks.TryGetValue(s.FirstTrack, out startTrack)) if (!aTracks.TryGetValue(s.FirstTrack, out var startTrack))
{ {
break; break;
} }
if (!aTracks.TryGetValue(s.LastTrack, out endTrack)) if (!aTracks.TryGetValue(s.LastTrack, out var endTrack))
{ {
break; break;
} }

View File

@ -341,8 +341,7 @@ namespace BizHawk.Emulation.DiscSystem
//read it if we dont have it cached //read it if we dont have it cached
//we wont be caching very much here, it's no big deal //we wont be caching very much here, it's no big deal
//identification is not something we want to take a long time //identification is not something we want to take a long time
byte[] data; if (!_sectorCache.TryGetValue(lba, out var data))
if (!_sectorCache.TryGetValue(lba, out data))
{ {
data = new byte[2048]; data = new byte[2048];
int read = _dsr.ReadLBA_2048(lba, data, 0); int read = _dsr.ReadLBA_2048(lba, data, 0);

View File

@ -63,15 +63,13 @@ namespace BizHawk.Emulation.DiscSystem
public static int BCDToInt(byte n) public static int BCDToInt(byte n)
{ {
var bcd = new BCD2(); var bcd = new BCD2 { BCDValue = n };
bcd.BCDValue = n;
return bcd.DecimalValue; return bcd.DecimalValue;
} }
public static byte IntToBCD(int n) public static byte IntToBCD(int n)
{ {
int ones; int tens = Math.DivRem(n, 10, out var ones);
int tens = Math.DivRem(n, 10, out ones);
return (byte)((tens << 4) | ones); return (byte)((tens << 4) | ones);
} }

View File

@ -6,8 +6,7 @@ namespace BizHawk.Emulation.DiscSystem
{ {
static byte IntToBCD(int n) static byte IntToBCD(int n)
{ {
int ones; int tens = Math.DivRem(n, 10, out var ones);
int tens = Math.DivRem(n, 10, out ones);
return (byte)((tens << 4) | ones); return (byte)((tens << 4) | ones);
} }
@ -37,7 +36,5 @@ namespace BizHawk.Emulation.DiscSystem
{ {
return f + (s * 75) + (m * 75 * 60) - 150; return f + (s * 75) + (m * 75 * 60) - 150;
} }
} }
} }

View File

@ -4,7 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Cyotek.Drawing.BitmapFont;
using sd=System.Drawing; using sd=System.Drawing;
namespace BizHawk.Bizware.BizwareGL namespace BizHawk.Bizware.BizwareGL
@ -61,8 +61,7 @@ namespace BizHawk.Bizware.BizwareGL
continue; continue;
} }
Cyotek.Drawing.BitmapFont.Character bfc; if (!FontInfo.Characters.TryGetValue((char)c, out var bfc))
if (!FontInfo.Characters.TryGetValue((char)c, out bfc))
bfc = FontInfo.Characters[unchecked((char)-1)]; bfc = FontInfo.Characters[unchecked((char)-1)];
x += bfc.XAdvance; x += bfc.XAdvance;
@ -98,8 +97,7 @@ namespace BizHawk.Bizware.BizwareGL
continue; continue;
} }
Cyotek.Drawing.BitmapFont.Character bfc; if (!FontInfo.Characters.TryGetValue((char)c, out var bfc))
if (!FontInfo.Characters.TryGetValue((char)c, out bfc))
bfc = FontInfo.Characters[unchecked((char)-1)]; bfc = FontInfo.Characters[unchecked((char)-1)];
// calculate texcoords (we shouldve already had this cached, but im speedcoding now) // calculate texcoords (we shouldve already had this cached, but im speedcoding now)