time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

_listCacheDelete.js (775B)


      1 var assocIndexOf = require('./_assocIndexOf');
      2 
      3 /** Used for built-in method references. */
      4 var arrayProto = Array.prototype;
      5 
      6 /** Built-in value references. */
      7 var splice = arrayProto.splice;
      8 
      9 /**
     10  * Removes `key` and its value from the list cache.
     11  *
     12  * @private
     13  * @name delete
     14  * @memberOf ListCache
     15  * @param {string} key The key of the value to remove.
     16  * @returns {boolean} Returns `true` if the entry was removed, else `false`.
     17  */
     18 function listCacheDelete(key) {
     19   var data = this.__data__,
     20       index = assocIndexOf(data, key);
     21 
     22   if (index < 0) {
     23     return false;
     24   }
     25   var lastIndex = data.length - 1;
     26   if (index == lastIndex) {
     27     data.pop();
     28   } else {
     29     splice.call(data, index, 1);
     30   }
     31   --this.size;
     32   return true;
     33 }
     34 
     35 module.exports = listCacheDelete;