Skip to content

Commit 72ee8f6

Browse files
committed
refactor: b2MakeSimplexFromCache to use 'in' parameters
- Changed `b2MakeSimplexFromCache` signature to accept `B2SimplexCache` and `B2ShapeProxy` as `in` parameters instead of `ref`. - Updated call sites to remove `ref` keyword. - This change optimizes performance by reducing struct copying and ensures read-only access to cache and proxy data.
1 parent 656754c commit 72ee8f6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Box2D.NET/B2Distances.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ internal static int b2FindSupport(ref B2ShapeProxy proxy, B2Vec2 direction)
210210
return bestIndex;
211211
}
212212

213-
public static B2Simplex b2MakeSimplexFromCache(ref B2SimplexCache cache, ref B2ShapeProxy proxyA, ref B2ShapeProxy proxyB)
213+
public static B2Simplex b2MakeSimplexFromCache(in B2SimplexCache cache, in B2ShapeProxy proxyA, in B2ShapeProxy proxyB)
214214
{
215215
B2_ASSERT(cache.count <= 3);
216216
B2Simplex s = new B2Simplex();
@@ -491,7 +491,7 @@ public static B2DistanceOutput b2ShapeDistance(ref B2DistanceInput input, ref B2
491491
}
492492

493493
// Initialize the simplex.
494-
B2Simplex simplex = b2MakeSimplexFromCache(ref cache, ref proxyA, ref localProxyB);
494+
B2Simplex simplex = b2MakeSimplexFromCache(cache, proxyA, localProxyB);
495495

496496
int simplexIndex = 0;
497497
if (simplexes != null && simplexIndex < simplexCapacity)

0 commit comments

Comments
 (0)