Bug 488182 - Use an Iterator to grab both key and values from cleartext for processing bookmarks

Get rid of extra record.cleartext references within the for/each/switch -- even for unused keys like incomingSharedAnno.
This commit is contained in:
Edward Lee 2009-04-13 16:18:11 -05:00
Родитель 3bd7c7fccf
Коммит 73ea5a7a89
1 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -350,33 +350,33 @@ BookmarksStore.prototype = {
this._bms.moveItem(itemId, parentid, record.sortindex); this._bms.moveItem(itemId, parentid, record.sortindex);
} }
for (let key in record.cleartext) { for (let [key, val] in Iterator(record.cleartext)) {
switch (key) { switch (key) {
case "title": case "title":
this._bms.setItemTitle(itemId, record.cleartext.title); this._bms.setItemTitle(itemId, val);
break; break;
case "uri": case "uri":
this._bms.changeBookmarkURI(itemId, Utils.makeURI(record.cleartext.uri)); this._bms.changeBookmarkURI(itemId, Utils.makeURI(val));
break; break;
case "tags": { case "tags": {
// filter out null/undefined/empty tags // filter out null/undefined/empty tags
let tags = record.cleartext.tags.filter(function(t) t); let tags = val.filter(function(t) t);
let tagsURI = this._bms.getBookmarkURI(itemId); let tagsURI = this._bms.getBookmarkURI(itemId);
this._ts.untagURI(tagsURI, null); this._ts.untagURI(tagsURI, null);
this._ts.tagURI(tagsURI, tags); this._ts.tagURI(tagsURI, tags);
} break; } break;
case "keyword": case "keyword":
this._bms.setKeywordForBookmark(itemId, record.cleartext.keyword); this._bms.setKeywordForBookmark(itemId, val);
break; break;
case "description": case "description":
this._ans.setItemAnnotation(itemId, "bookmarkProperties/description", this._ans.setItemAnnotation(itemId, "bookmarkProperties/description",
record.cleartext.description, 0, val, 0,
this._ans.EXPIRE_NEVER); this._ans.EXPIRE_NEVER);
break; break;
case "generatorURI": { case "generatorURI": {
try { try {
let micsumURI = Utils.makeURI(this._bms.getBookmarkURI(itemId)); let micsumURI = Utils.makeURI(this._bms.getBookmarkURI(itemId));
let genURI = Utils.makeURI(record.cleartext.generatorURI); let genURI = Utils.makeURI(val);
if (this._ms == SERVICE_NOT_SUPPORTED) { if (this._ms == SERVICE_NOT_SUPPORTED) {
this._log.warn("Can't create microsummary -- not supported."); this._log.warn("Can't create microsummary -- not supported.");
} else { } else {
@ -388,24 +388,24 @@ BookmarksStore.prototype = {
} }
} break; } break;
case "siteURI": case "siteURI":
this._ls.setSiteURI(itemId, Utils.makeURI(record.cleartext.siteURI)); this._ls.setSiteURI(itemId, Utils.makeURI(val));
break; break;
case "feedURI": case "feedURI":
this._ls.setFeedURI(itemId, Utils.makeURI(record.cleartext.feedURI)); this._ls.setFeedURI(itemId, Utils.makeURI(val));
break; break;
case "outgoingSharedAnno": case "outgoingSharedAnno":
this._ans.setItemAnnotation(itemId, OUTGOING_SHARED_ANNO, this._ans.setItemAnnotation(itemId, OUTGOING_SHARED_ANNO,
record.cleartext.outgoingSharedAnno, 0, val, 0,
this._ans.EXPIRE_NEVER); this._ans.EXPIRE_NEVER);
break; break;
case "incomingSharedAnno": case "incomingSharedAnno":
this._ans.setItemAnnotation(itemId, INCOMING_SHARED_ANNO, this._ans.setItemAnnotation(itemId, INCOMING_SHARED_ANNO,
record.cleartext.incomingSharedAnno, 0, val, 0,
this._ans.EXPIRE_NEVER); this._ans.EXPIRE_NEVER);
break; break;
case "serverPathAnno": case "serverPathAnno":
this._ans.setItemAnnotation(itemId, SERVER_PATH_ANNO, this._ans.setItemAnnotation(itemId, SERVER_PATH_ANNO,
record.cleartext.serverPathAnno, 0, val, 0,
this._ans.EXPIRE_NEVER); this._ans.EXPIRE_NEVER);
break; break;
} }