@@ -378,11 +378,11 @@ const GLSpec = struct {
378
378
try writer .print ("{s}" , .{zigTypeDefs });
379
379
try writer .print ("\n\n " , .{});
380
380
381
- var enums = std .ArrayList ([] const u8 ).init (self .allocator );
382
- defer enums .deinit ();
381
+ var enumNames = std .StringHashMap ( void ).init (self .allocator );
382
+ defer enumNames .deinit ();
383
383
384
- var commands = std .ArrayList ([] const u8 ).init (self .allocator );
385
- defer commands .deinit ();
384
+ var commandNames = std .StringHashMap ( void ).init (self .allocator );
385
+ defer commandNames .deinit ();
386
386
387
387
// try commands.append("glGetShaderSource");
388
388
@@ -396,23 +396,30 @@ const GLSpec = struct {
396
396
}
397
397
398
398
for (featureSet .enums ) | enumSet | {
399
- try enums .appendSlice (enumSet );
399
+ for (enumSet ) | enumName | {
400
+ try enumNames .put (enumName , {});
401
+ }
400
402
}
401
403
402
404
for (featureSet .commands ) | commandSet | {
403
- try commands .appendSlice (commandSet );
405
+ for (commandSet ) | commandName | {
406
+ try commandNames .put (commandName , {});
407
+ }
404
408
}
405
409
}
406
410
407
- for (enums .items ) | enumName | {
408
- const @"enum" = enumQuickSet .get (enumName ) orelse unreachable ;
411
+ var enumIter = enumNames .keyIterator ();
412
+ var commandIter = commandNames .keyIterator ();
413
+
414
+ while (enumIter .next ()) | enumName | {
415
+ const @"enum" = enumQuickSet .get (enumName .* ) orelse unreachable ;
409
416
try writer .print ("{}\n " , .{@"enum" });
410
417
}
411
418
412
419
try writer .print ("\n " , .{});
413
420
414
- for ( commands . items ) | commandName | {
415
- const command = commandQuickSet .get (commandName ) orelse unreachable ;
421
+ while ( commandIter . next () ) | commandName | {
422
+ const command = commandQuickSet .get (commandName .* ) orelse unreachable ;
416
423
try writer .print ("{}\n " , .{Command.Formatter { .allocator = self .allocator , .command = command , .static = self .static }});
417
424
}
418
425
@@ -446,9 +453,10 @@ const GLSpec = struct {
446
453
try writer .print (
447
454
\\pub fn init() void {{
448
455
, .{});
449
- for (commands .items ) | commandName | {
456
+ var commandIter2 = commandNames .keyIterator ();
457
+ while (commandIter2 .next ()) | commandName | {
450
458
try writer .print ("\n " , .{});
451
- const command = commandQuickSet .get (commandName ) orelse unreachable ;
459
+ const command = commandQuickSet .get (commandName .* ) orelse unreachable ;
452
460
try writer .print (
453
461
\\ {} = @ptrCast(loadFn("{s}") orelse @panic("Cannot find proc \"{s}\""));
454
462
, .{ formatSymbol (command .prototype .name ), command .prototype .name , command .prototype .name });
@@ -496,10 +504,13 @@ pub fn main() !void {
496
504
};
497
505
498
506
var isWasm = false ;
507
+ var time = false ;
499
508
while (args .next ()) | arg | {
500
509
if (std .mem .eql (u8 , arg , "--static" )) isWasm = true ;
510
+ if (std .mem .eql (u8 , arg , "--time" )) time = true ;
501
511
}
502
512
513
+ const us1 = std .time .microTimestamp ();
503
514
var document = try xml .parseXmlFull (gpa .allocator (), @embedFile ("gl.xml" ));
504
515
defer document .deinit ();
505
516
@@ -538,4 +549,8 @@ pub fn main() !void {
538
549
\\//
539
550
, .{ "2024" , api , version , isWasm });
540
551
try outFile .writer ().print ("\n {}" , .{formatter });
552
+ const us2 = std .time .microTimestamp ();
553
+ const ms : usize = @intCast (@divFloor (us2 - us1 , 1000 ));
554
+
555
+ if (time ) try std .io .getStdOut ().writer ().print ("took {}ms" , .{ms });
541
556
}
0 commit comments