I look at some C code and notice that it is filled with these curly braces surrounding the blocks of code without any control structure. Take a look:
//do some stuff . . . fprintf(stderr, "%.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC); { //a block! why not? char *tmp_argv[3]; tmp_argv[0] = argv[0]; tmp_argv[1] = str; tmp_argv[2] = prefix; t = clock(); fprintf(stderr, "[bwa_index] Convert nucleotide PAC to color PAC... "); bwa_pac2cspac(3, tmp_argv); fprintf(stderr, "%.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC); }
Why would you insert such blocks into your code? It is filled with them. Is there any kind of performance? Something mystical C? Why???
edit: This code, if from BWA , is a bioinformatics program that aligns small sequences with large references using the Burrows-Wheeler transform , if you're interested. This sample code is not particularly relevant to the functionality of the application.
c scope curly-braces
jergason Nov 05 '09 at 1:25 2009-11-05 01:25
source share