<commit_before>import AbstractAdapter from './abstract';
import Ember from 'ember';

/**
 * @module ember-cli-storagekit
 * @submodule adapters
 */

/**
 * @class InstanceAdapter
 * @extends EmberCliStoragekit.AbstractAdapter
 * @requires Ember.Map
 * @public
 */

export default AbstractAdapter.extend({

  storage: Ember.computed(function () {
    return Ember.Map.create();
  }).readOnly(),

  /**
   * @override
   */
  setItem(key, value) {
    this.get('storage').set(this.buildNamespace(key), this.get('serializer').serialize(value));
  },

  /**
   * @override
   */
  getItem(key) {
    return this.get('serializer').deserialize(this.get('storage').get(this.buildNamespace(key)));
  },

  /**
   * @override
   */
  removeItem(key){
    this.get('storage').delete(this.buildNamespace(key));
  },

  /**
   * @override
   */
  keys() {
    const keys = [];

    this.get('storage').forEach((value, key) => {
      if(this.isNamespaced(key)) {
        keys.push(key);
      }
    });

    return keys
      .map(key => this.stripNamespace(key))
      .sort();
  },

  /**
   * @override
   */
  clear() {
    this.keys().forEach(key => this.removeItem(key));
  }
});<commit_msg>small refactor to eliminate additional pass on keys array<commit_after>import AbstractAdapter from './abstract';
import Ember from 'ember';

/**
 * @module ember-cli-storagekit
 * @submodule adapters
 */

/**
 * @class InstanceAdapter
 * @extends EmberCliStoragekit.AbstractAdapter
 * @requires Ember.Map
 * @public
 */

export default AbstractAdapter.extend({

  storage: Ember.computed(function () {
    return Ember.Map.create();
  }).readOnly(),

  /**
   * @override
   */
  setItem(key, value) {
    this.get('storage').set(this.buildNamespace(key), this.get('serializer').serialize(value));
  },

  /**
   * @override
   */
  getItem(key) {
    return this.get('serializer').deserialize(this.get('storage').get(this.buildNamespace(key)));
  },

  /**
   * @override
   */
  removeItem(key){
    this.get('storage').delete(this.buildNamespace(key));
  },

  /**
   * @override
   */
  keys() {
    const keys = [];

    this.get('storage').forEach((value, key) => {
      if(this.isNamespaced(key)) {
        keys.push(this.stripNamespace(key));
      }
    });

    return keys.sort();
  },

  /**
   * @override
   */
  clear() {
    this.keys().forEach(key => this.removeItem(key));
  }
});
{'fraction_non_alphanumeric': 0.1891778523489933, 'fraction_numerical': 0.0, 'mean_word_length': 3.0287162162162162, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4792193', 'n_tokens_mistral': 799, 'n_tokens_neox': 778, 'n_words': 117}