Skip to content

Commit 8e1e2ad

Browse files
committed
Reorder code
Doesn't seem to affect OpenGL bindings generation This is to ensure all trimming code happens after rewinding, which is useful because I'm thinking of refactoring this code and want to ensure that I can treat all of the trimming code equally.
1 parent d795e5f commit 8e1e2ad

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

sources/SilkTouch/SilkTouch/Mods/MixKhronosData.cs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,46 @@ ref string? identifiedPrefix
11311131
);
11321132
}
11331133

1134+
// Sometimes we get a little overzealous, so let's unwind back to just the GL_ being snipped
1135+
var rewind = false;
1136+
if (container is not null && job.Groups.ContainsKey(container))
1137+
{
1138+
foreach (var (_, (current, previous)) in names)
1139+
{
1140+
var prev = previous?.FirstOrDefault();
1141+
if (
1142+
prev is not null
1143+
&& current.AsSpan().Count('_') - prev.AsSpan().Count('_') <= 1
1144+
&& (current.Length <= 4 || (job.Vendors?.Contains(current) ?? false))
1145+
)
1146+
{
1147+
rewind = true;
1148+
1149+
break;
1150+
}
1151+
}
1152+
}
1153+
1154+
if (rewind)
1155+
{
1156+
foreach (var (original, (current, previous)) in names)
1157+
{
1158+
var prev = previous?.FirstOrDefault() ?? original;
1159+
var prevList = previous ?? [];
1160+
var next = prev[(prev.IndexOf('_') + 1)..];
1161+
if (next == prev)
1162+
{
1163+
prevList.Remove(prev);
1164+
}
1165+
else if (!prevList.Contains(prev))
1166+
{
1167+
prevList.Add(prev);
1168+
}
1169+
1170+
names[original] = (prev[(prev.IndexOf('_') + 1)..], prevList);
1171+
}
1172+
}
1173+
11341174
// OpenGL has a problem where an enum starts out as ARB but never gets promoted, and then contains other vendor
11351175
// enums or even core enums. This removes the vendor suffix where it is not necessary e.g. BufferUsageARB
11361176
// becomes BufferUsage.
@@ -1183,46 +1223,6 @@ vendorSuffix is null
11831223
}
11841224
}
11851225

1186-
// Sometimes we get a little overzealous, so let's unwind back to just the GL_ being snipped
1187-
var rewind = false;
1188-
if (container is not null && job.Groups.ContainsKey(container))
1189-
{
1190-
foreach (var (_, (current, previous)) in names)
1191-
{
1192-
var prev = previous?.FirstOrDefault();
1193-
if (
1194-
prev is not null
1195-
&& current.AsSpan().Count('_') - prev.AsSpan().Count('_') <= 1
1196-
&& (current.Length <= 4 || (job.Vendors?.Contains(current) ?? false))
1197-
)
1198-
{
1199-
rewind = true;
1200-
1201-
break;
1202-
}
1203-
}
1204-
}
1205-
1206-
if (rewind)
1207-
{
1208-
foreach (var (original, (current, previous)) in names)
1209-
{
1210-
var prev = previous?.FirstOrDefault() ?? original;
1211-
var prevList = previous ?? [];
1212-
var next = prev[(prev.IndexOf('_') + 1)..];
1213-
if (next == prev)
1214-
{
1215-
prevList.Remove(prev);
1216-
}
1217-
else if (!prevList.Contains(prev))
1218-
{
1219-
prevList.Add(prev);
1220-
}
1221-
1222-
names[original] = (prev[(prev.IndexOf('_') + 1)..], prevList);
1223-
}
1224-
}
1225-
12261226
// Trim the extension vendor names
12271227
foreach (var (original, (current, previous)) in names)
12281228
{

0 commit comments

Comments
 (0)