comparison src/c/urweb.c @ 921:ae0110465421

Don't replace <sc> in blob returns; optimize more 'option' pattern matches; detect more opportunities for 'let' inlining
author Adam Chlipala <adamc@hcoop.net>
date Wed, 09 Sep 2009 08:00:45 -0400
parents 321a2d6feb40
children d6a71f19a3d8
comparison
equal deleted inserted replaced
920:7accd4546cf9 921:ae0110465421
344 struct uw_context { 344 struct uw_context {
345 char *(*get_header)(void *, const char *); 345 char *(*get_header)(void *, const char *);
346 void *get_header_data; 346 void *get_header_data;
347 347
348 buf outHeaders, page, heap, script; 348 buf outHeaders, page, heap, script;
349 int returning_blob;
349 input *inputs, *subinputs, *cur_container; 350 input *inputs, *subinputs, *cur_container;
350 size_t n_subinputs, used_subinputs; 351 size_t n_subinputs, used_subinputs;
351 352
352 int source_count; 353 int source_count;
353 354
384 ctx->get_header = NULL; 385 ctx->get_header = NULL;
385 ctx->get_header_data = NULL; 386 ctx->get_header_data = NULL;
386 387
387 buf_init(&ctx->outHeaders, 0); 388 buf_init(&ctx->outHeaders, 0);
388 buf_init(&ctx->page, 0); 389 buf_init(&ctx->page, 0);
390 ctx->returning_blob = 0;
389 buf_init(&ctx->heap, 0); 391 buf_init(&ctx->heap, 0);
390 buf_init(&ctx->script, 1); 392 buf_init(&ctx->script, 1);
391 ctx->script.start[0] = 0; 393 ctx->script.start[0] = 0;
392 394
393 ctx->inputs = calloc(uw_inputs_len, sizeof(input)); 395 ctx->inputs = calloc(uw_inputs_len, sizeof(input));
456 458
457 buf_reset(&ctx->outHeaders); 459 buf_reset(&ctx->outHeaders);
458 buf_reset(&ctx->script); 460 buf_reset(&ctx->script);
459 ctx->script.start[0] = 0; 461 ctx->script.start[0] = 0;
460 buf_reset(&ctx->page); 462 buf_reset(&ctx->page);
463 ctx->returning_blob = 0;
461 buf_reset(&ctx->heap); 464 buf_reset(&ctx->heap);
462 ctx->regions = NULL; 465 ctx->regions = NULL;
463 ctx->cleanup_front = ctx->cleanup; 466 ctx->cleanup_front = ctx->cleanup;
464 ctx->source_count = 0; 467 ctx->source_count = 0;
465 ctx->used_deltas = 0; 468 ctx->used_deltas = 0;
2547 2550
2548 for (i = 0; i < ctx->used_transactionals; ++i) 2551 for (i = 0; i < ctx->used_transactionals; ++i)
2549 ctx->transactionals[i].free(ctx->transactionals[i].data); 2552 ctx->transactionals[i].free(ctx->transactionals[i].data);
2550 2553
2551 // Splice script data into appropriate part of page 2554 // Splice script data into appropriate part of page
2552 if (ctx->script_header[0] == 0) 2555 if (ctx->returning_blob || ctx->script_header[0] == 0)
2553 ; 2556 ;
2554 else if (buf_used(&ctx->script) == 0) { 2557 else if (buf_used(&ctx->script) == 0) {
2555 size_t len = strlen(ctx->script_header); 2558 size_t len = strlen(ctx->script_header);
2556 char *start = strstr(ctx->page.start, "<sc>"); 2559 char *start = strstr(ctx->page.start, "<sc>");
2557 if (start) { 2560 if (start) {
2774 2777
2775 __attribute__((noreturn)) void uw_return_blob(uw_context ctx, uw_Basis_blob b, uw_Basis_string mimeType) { 2778 __attribute__((noreturn)) void uw_return_blob(uw_context ctx, uw_Basis_blob b, uw_Basis_string mimeType) {
2776 cleanup *cl; 2779 cleanup *cl;
2777 int len; 2780 int len;
2778 2781
2782 ctx->returning_blob = 1;
2779 buf_reset(&ctx->outHeaders); 2783 buf_reset(&ctx->outHeaders);
2780 buf_reset(&ctx->page); 2784 buf_reset(&ctx->page);
2781 2785
2782 uw_write_header(ctx, on_success); 2786 uw_write_header(ctx, on_success);
2783 uw_write_header(ctx, "Content-Type: "); 2787 uw_write_header(ctx, "Content-Type: ");