Skip to content

Commit

Permalink
Some additional performance improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
genaray committed Aug 7, 2024
1 parent 2a28388 commit 7c15424
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/Arch.SourceGen/Fundamentals/Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ public static StringBuilder AppendChunkIndexGet(this StringBuilder sb, int amoun
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var inParams = new StringBuilder().InsertGenericParams(amount);
var arrays = new StringBuilder().GetChunkArrays(amount);
var arrays = new StringBuilder().GetChunkFirstGenericElements(amount);

var gets = new StringBuilder();
for (var index = 0; index <= amount; index++)
{
gets.AppendLine($"ref var t{index}Component = ref t{index}Array[index];");
gets.AppendLine($"ref var t{index}Component = ref Unsafe.Add(ref t{index}FirstElement, index);");
}

var template =
Expand Down Expand Up @@ -186,13 +186,13 @@ public static StringBuilder AppendChunkIndexGetRows(this StringBuilder sb, int a
public static StringBuilder AppendChunkIndexGetRow(this StringBuilder sb, int amount)
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var getArrays = new StringBuilder().GetChunkArrays(amount);
var getArrays = new StringBuilder().GetChunkFirstGenericElements(amount);
var inParams = new StringBuilder().InsertGenericParams(amount);

var gets = new StringBuilder();
for (var index = 0; index <= amount; index++)
{
gets.AppendLine($"ref var t{index}Component = ref t{index}Array[index];");
gets.AppendLine($"ref var t{index}Component = ref Unsafe.Add(ref t{index}FirstElement, index);");
}

var template =
Expand All @@ -203,7 +203,7 @@ public static StringBuilder AppendChunkIndexGetRow(this StringBuilder sb, int am
{
{{getArrays}}
ref var entity = ref Entities[index];
ref var entity = ref Entity(index);
{{gets}}
return new EntityComponents<{{generics}}>(ref entity, {{inParams}});
Expand Down
6 changes: 3 additions & 3 deletions src/Arch.SourceGen/Fundamentals/Set.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public static StringBuilder AppendChunkIndexSet(this StringBuilder sb, int amoun
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var parameters = new StringBuilder().GenericInParams(amount);
var arrays = new StringBuilder().GetChunkArrays(amount);
var arrays = new StringBuilder().GetChunkFirstGenericElements(amount);

var sets = new StringBuilder();
for (var index = 0; index <= amount; index++)
{
sets.AppendLine($"t{index}Array[index] = t{index}Component;");
sets.AppendLine($"Unsafe.Add(ref t{index}FirstElement, index) = t{index}Component;");
}

var template =
Expand Down Expand Up @@ -80,7 +80,7 @@ public static StringBuilder AppendArchetypeSetRange(this StringBuilder sb, int a
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var parameters = new StringBuilder().GenericInDefaultParams(amount,"ComponentValue");
var getFirstElements = new StringBuilder().GetFirstGenericElements(amount);
var getFirstElements = new StringBuilder().GetChunkFirstGenericElements(amount);
var getComponents = new StringBuilder().GetGenericComponents(amount);

var assignComponents = new StringBuilder();
Expand Down
8 changes: 4 additions & 4 deletions src/Arch.SourceGen/Queries/InlineQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static StringBuilder AppendQueryInterfaceMethods(this StringBuilder build
for (var index = 0; index <= amount; index++)
{
var generics = new StringBuilder().GenericWithoutBrackets(index);
var getFirstElement = new StringBuilder().GetFirstGenericElements(index);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(index);
var getComponents = new StringBuilder().GetGenericComponents(index);
var insertParams = new StringBuilder().InsertGenericParams(index);

Expand Down Expand Up @@ -111,7 +111,7 @@ public static StringBuilder AppendQueryInterfaceMethods(this StringBuilder build
for (var index = 0; index <= amount; index++)
{
var generics = new StringBuilder().GenericWithoutBrackets(index);
var getFirstElement = new StringBuilder().GetFirstGenericElements(index);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(index);
var getComponents = new StringBuilder().GetGenericComponents(index);
var insertParams = new StringBuilder().InsertGenericParams(index);

Expand Down Expand Up @@ -148,7 +148,7 @@ public static StringBuilder AppendEntityQueryInterfaceMethods(this StringBuilder
for (var index = 0; index <= amount; index++)
{
var generics = new StringBuilder().GenericWithoutBrackets(index);
var getFirstElement = new StringBuilder().GetFirstGenericElements(index);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(index);
var getComponents = new StringBuilder().GetGenericComponents(index);
var insertParams = new StringBuilder().InsertGenericParams(index);

Expand Down Expand Up @@ -181,7 +181,7 @@ public static StringBuilder AppendEntityQueryInterfaceMethods(this StringBuilder
for (var index = 0; index <= amount; index++)
{
var generics = new StringBuilder().GenericWithoutBrackets(index);
var getFirstElement = new StringBuilder().GetFirstGenericElements(index);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(index);
var getComponents = new StringBuilder().GetGenericComponents(index);
var insertParams = new StringBuilder().InsertGenericParams(index);

Expand Down
8 changes: 4 additions & 4 deletions src/Arch.SourceGen/Queries/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static void AppendForEachJobs(this StringBuilder sb, int amount)
public static void AppendForEachJob(this StringBuilder sb, int amount)
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var getFirstElement = new StringBuilder().GetFirstGenericElements(amount);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount);
var getComponents = new StringBuilder().GetGenericComponents(amount);
var insertParams = new StringBuilder().InsertGenericParams(amount);

Expand Down Expand Up @@ -52,7 +52,7 @@ public static void AppendEntityForEachJobs(this StringBuilder sb, int amount)
public static void AppendEntityForEachJob(this StringBuilder sb, int amount)
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var getFirstElement = new StringBuilder().GetFirstGenericElements(amount);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount);
var getComponents = new StringBuilder().GetGenericComponents(amount);
var insertParams = new StringBuilder().InsertGenericParams(amount);

Expand Down Expand Up @@ -93,7 +93,7 @@ public static void AppendIForEachJobs(this StringBuilder sb, int amount)
public static void AppendIForEachJob(this StringBuilder sb, int amount)
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var getFirstElement = new StringBuilder().GetFirstGenericElements(amount);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount);
var getComponents = new StringBuilder().GetGenericComponents(amount);
var insertParams = new StringBuilder().InsertGenericParams(amount);

Expand Down Expand Up @@ -132,7 +132,7 @@ public static void AppendIForEachWithEntityJobs(this StringBuilder sb, int amoun
public static void AppendIForEachWithEntityJob(this StringBuilder sb, int amount)
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var getFirstElement = new StringBuilder().GetFirstGenericElements(amount);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount);
var getComponents = new StringBuilder().GetGenericComponents(amount);
var insertParams = new StringBuilder().InsertGenericParams(amount);

Expand Down
4 changes: 2 additions & 2 deletions src/Arch.SourceGen/Queries/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static StringBuilder AppendQueryMethods(this StringBuilder sb, int amount
public static StringBuilder AppendQueryMethod(this StringBuilder sb, int amount)
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var getFirstElement = new StringBuilder().GetFirstGenericElements(amount);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount);
var getComponents = new StringBuilder().GetGenericComponents(amount);
var insertParams = new StringBuilder().InsertGenericParams(amount);

Expand Down Expand Up @@ -103,7 +103,7 @@ public static StringBuilder AppendEntityQueryMethods(this StringBuilder sb, int
public static StringBuilder AppendEntityQueryMethod(this StringBuilder sb, int amount)
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var getFirstElement = new StringBuilder().GetFirstGenericElements(amount);
var getFirstElement = new StringBuilder().GetChunkFirstGenericElements(amount);
var getComponents = new StringBuilder().GetGenericComponents(amount);
var insertParams = new StringBuilder().InsertGenericParams(amount);

Expand Down
2 changes: 1 addition & 1 deletion src/Arch.SourceGen/Queries/SetWithQueryDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static StringBuilder AppendSetWithQueryDescriptions(this StringBuilder sb
public static void AppendSetWithQueryDescription(this StringBuilder sb, int amount)
{
var generics = new StringBuilder().GenericWithoutBrackets(amount);
var getFirsts = new StringBuilder().GetFirstGenericElements(amount);
var getFirsts = new StringBuilder().GetChunkFirstGenericElements(amount);
var getComponents = new StringBuilder().GetGenericComponents(amount);
var parameters = new StringBuilder().GenericInDefaultParams(amount,"ComponentValue");

Expand Down
2 changes: 1 addition & 1 deletion src/Arch.SourceGen/StringBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static StringBuilder GenericWithoutBrackets(this StringBuilder sb, int am
/// <param name="sb"></param>
/// <param name="amount"></param>
/// <returns></returns>
public static StringBuilder GetFirstGenericElements(this StringBuilder sb, int amount)
public static StringBuilder GetChunkFirstGenericElements(this StringBuilder sb, int amount)
{
for (var localIndex = 0; localIndex <= amount; localIndex++)
{
Expand Down

0 comments on commit 7c15424

Please sign in to comment.