Skip to content

Commit

Permalink
fix: simplify cache logic
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmuffin committed Oct 18, 2023
1 parent ed0fdbb commit 989d768
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions managed/CounterStrikeSharp.API/Modules/Memory/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ public class Schema
private static Dictionary<Tuple<string, string>, short> _schemaOffsets = new();
public static short GetSchemaOffset(string className, string propertyName)
{
if (_schemaOffsets.TryGetValue(new Tuple<string, string>(className, propertyName), out var offset))
var key = new Tuple<string, string>(className, propertyName);
if (!_schemaOffsets.TryGetValue(key, out var offset))
{
return offset;
offset = NativeAPI.GetSchemaOffset(className, propertyName);
_schemaOffsets.Add(key, offset);
}

var foundOffset = NativeAPI.GetSchemaOffset(className, propertyName);
_schemaOffsets.Add(new Tuple<string, string>(className, propertyName), foundOffset);
return foundOffset;
return offset;
}

public static T GetSchemaValue<T>(IntPtr handle, string className, string propertyName)
Expand Down

0 comments on commit 989d768

Please sign in to comment.