pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:7067:    }    }    n=findstring(name);    if(!n) return -1;    return find_shared_string_identifier(n,prog);   }      int store_prog_string(struct pike_string *str)   {    unsigned int i; -  +  if( str->refs > 1 )    for (i=0;i<Pike_compiler->new_program->num_strings;i++)    if (Pike_compiler->new_program->strings[i] == str)    return i;       reference_shared_string(str);    add_to_strings(str); -  return i; +  return Pike_compiler->new_program->num_strings-1;   }      /* NOTE: O(n²)! */   int store_constant(const struct svalue *foo,    int equal,    struct pike_string *UNUSED(constant_name))   {    struct program_constant tmp;    volatile unsigned int e;       JMP_BUF jmp;    if (SETJMP(jmp)) {    handle_compile_exception ("Error comparing constants.");    /* Assume that if `==() throws an error, the svalues aren't equal. */    e = Pike_compiler->new_program->num_constants;    } else { -  +  if(!equal && +  (TYPEOF(*foo) == PIKE_T_MAPPING || +  TYPEOF(*foo) == PIKE_T_MULTISET || +  TYPEOF(*foo) == PIKE_T_STRING || +  TYPEOF(*foo) == PIKE_T_ARRAY )) /* no possibility of comparator. Check refs first. */ +  { +  if(*foo->u.refs == 1 ) +  { +  e = Pike_compiler->new_program->num_constants; +  goto not_present; +  } +  } +     for(e=0;e<Pike_compiler->new_program->num_constants;e++)    {    struct program_constant *c = Pike_compiler->new_program->constants+e;       if (TYPEOF(*foo) == TYPEOF(c->sval)) {    /* Make sure only to compare within the same basic type. */    if (TYPEOF(*foo) == T_OBJECT) {    /* Special case objects -- We don't want strange LFUN effects... */    if ((foo->u.object == c->sval.u.object) &&    (SUBTYPEOF(*foo) == SUBTYPEOF(c->sval))) {
pike.git/src/program.c:7119:    return e;    }    }    } else if(equal ? is_equal(& c->sval,foo) : is_eq(& c->sval,foo)) {    UNSETJMP(jmp);    return e;    }    }    }    } + not_present:    UNSETJMP(jmp);    assign_svalue_no_free(&tmp.sval,foo);   #if 0    if((tmp.name=constant_name)) add_ref(constant_name);   #else /* !0 */    tmp.offset = -1;   #endif /* 0 */       add_to_constants(tmp);