pike.git / src / mapping.c

version» Context lines:

pike.git/src/mapping.c:316:    if(!(k = from)) return;       /* Reverse the hash chain. */    while ((next = k->next)) {    k->next = prev;    prev = k;    k = next;    }    k->next = prev;    -  from = k; +  prev = k;       /* Rehash and reverse the hash chain. */ -  while (from) { +  while ((from = prev)) { +  /* Reverse */ +  prev = from->next; +  from->next = next; +  next = from; +     if (md->flags & MAPPING_WEAK) {       switch(md->flags & MAPPING_WEAK) {    default:    Pike_fatal("Instable mapping data flags.\n");    case MAPPING_WEAK_INDICES:    if ((TYPEOF(from->ind) <= MAX_REF_TYPE) &&    (*from->ind.u.refs > 1)) {    goto keep_keypair;    }
pike.git/src/mapping.c:353:    }    break;    }       /* Free.    * Note that we don't need to free or unlink the keypair,    * since that will be done by the caller anyway. */    free_svalue(&from->ind);    free_svalue(&from->val);    -  /* Reverse */ -  prev = from->next; -  from->next = next; -  next = from; -  from = prev; -  +     continue;    }    keep_keypair:       /* unlink */    k=md->free_list;   #ifndef PIKE_MAPPING_KEYPAIR_LOOP   #ifdef PIKE_DEBUG    if(!k) Pike_fatal("Error in rehash: not enough keypairs.\n");   #endif
pike.git/src/mapping.c:387:    /* link */    h=k->hval;    h&=md->hashsize - 1;    k->next=md->hash[h];    md->hash[h]=k;       /* update */    md->ind_types |= 1<< (TYPEOF(k->ind));    md->val_types |= 1<< (TYPEOF(k->val));    md->size++; -  -  /* Reverse */ -  prev = from->next; -  from->next = next; -  next = from; -  from = prev; +     }   }      /* Good: Copy the svalues from the old md. */   static void mapping_rehash_backwards_good(struct mapping_data *md,    struct keypair *from)   {    unsigned INT32 h;    struct keypair *k, *prev = NULL, *next;       if(!(k = from)) return;       /* Reverse the hash chain. */    while ((next = k->next)) {    k->next = prev;    prev = k;    k = next;    }    k->next = prev;    -  from = k; +  prev = k;       /* Rehash and reverse the hash chain. */ -  while (from) { +  while ((from = prev)) { +  /* Reverse */ +  prev = from->next; +  from->next = next; +  next = from; +     if (md->flags & MAPPING_WEAK) {       switch(md->flags & MAPPING_WEAK) {    default:    Pike_fatal("Instable mapping data flags.\n");    case MAPPING_WEAK_INDICES:    if ((TYPEOF(from->ind) <= MAX_REF_TYPE) &&    (*from->ind.u.refs > 1)) {    goto keep_keypair;    }
pike.git/src/mapping.c:451:    break;    }       /* Skip copying of this keypair.    *    * NB: We can't mess with the original md here,    * since it might be in use by an iterator    * or similar.    */    -  /* Reverse */ -  prev = from->next; -  from->next = next; -  next = from; -  from = prev; -  +     continue;    }    keep_keypair:       /* unlink */    k=md->free_list;   #ifndef PIKE_MAPPING_KEYPAIR_LOOP   #ifdef PIKE_DEBUG    if(!k) Pike_fatal("Error in rehash: not enough keypairs.\n");   #endif
pike.git/src/mapping.c:487:    /* link */    h=k->hval;    h&=md->hashsize - 1;    k->next=md->hash[h];    md->hash[h]=k;       /* update */    md->ind_types |= 1<< (TYPEOF(k->ind));    md->val_types |= 1<< (TYPEOF(k->val));    md->size++; -  -  /* Reverse */ -  prev = from->next; -  from->next = next; -  next = from; -  from = prev; +     }   }      /** This function re-allocates a mapping. It adjusts the max no. of    * values can be fitted into the mapping. It takes a bit of time to    * run, but is used seldom enough not to degrade preformance significantly.    *    * @param m the mapping to be rehashed    * @param new_size new mappingsize    * @return the rehashed mapping