Skip to content

Commit b2e148a

Browse files
Optimize locked mvalue creation
1 parent 6dac619 commit b2e148a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

api/AltV.Net.Async/MValue.Locked.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,62 @@ public static class MValueLocked
1010
{
1111
public static MValue CreateLocked(IPlayer player)
1212
{
13+
var mValue = MValue.Nil;
1314
lock (player)
1415
{
1516
if (!player.Exists)
1617
{
1718
return MValue.Nil;
1819
}
19-
}
2020

21-
var mValue = MValue.Nil;
22-
AltNative.MValueCreate.MValue_CreatePlayer(player.NativePointer, ref mValue);
23-
return mValue;
21+
AltNative.MValueCreate.MValue_CreatePlayer(player.NativePointer, ref mValue);
22+
return mValue;
23+
}
2424
}
2525

2626
public static MValue CreateLocked(IVehicle vehicle)
2727
{
28+
var mValue = MValue.Nil;
2829
lock (vehicle)
2930
{
3031
if (!vehicle.Exists)
3132
{
3233
return MValue.Nil;
3334
}
34-
}
3535

36-
var mValue = MValue.Nil;
37-
AltNative.MValueCreate.MValue_CreateVehicle(vehicle.NativePointer, ref mValue);
38-
return mValue;
36+
AltNative.MValueCreate.MValue_CreateVehicle(vehicle.NativePointer, ref mValue);
37+
return mValue;
38+
}
3939
}
4040

4141
public static MValue CreateLocked(IBlip blip)
4242
{
43+
var mValue = MValue.Nil;
4344
lock (blip)
4445
{
4546
if (!blip.Exists)
4647
{
4748
return MValue.Nil;
4849
}
49-
}
5050

51-
var mValue = MValue.Nil;
52-
AltNative.MValueCreate.MValue_CreateBlip(blip.NativePointer, ref mValue);
53-
return mValue;
51+
AltNative.MValueCreate.MValue_CreateBlip(blip.NativePointer, ref mValue);
52+
return mValue;
53+
}
5454
}
5555

5656
public static MValue CreateLocked(ICheckpoint checkpoint)
5757
{
58+
var mValue = MValue.Nil;
5859
lock (checkpoint)
5960
{
6061
if (!checkpoint.Exists)
6162
{
6263
return MValue.Nil;
6364
}
64-
}
6565

66-
var mValue = MValue.Nil;
67-
AltNative.MValueCreate.MValue_CreateCheckpoint(checkpoint.NativePointer, ref mValue);
68-
return mValue;
66+
AltNative.MValueCreate.MValue_CreateCheckpoint(checkpoint.NativePointer, ref mValue);
67+
return mValue;
68+
}
6969
}
7070

7171
public static MValue CreateFromObjectLocked(object obj)

0 commit comments

Comments
 (0)