Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: chrome/browser/spellchecker/spellcheck_custom_dictionary.cc

Issue 23934009: [CleanUp] Use base::STLSetDifference() in place of std::set_difference() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" 5 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/important_file_writer.h" 10 #include "base/files/important_file_writer.h"
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 441 }
442 442
443 void SpellcheckCustomDictionary::Apply( 443 void SpellcheckCustomDictionary::Apply(
444 const SpellcheckCustomDictionary::Change& dictionary_change) { 444 const SpellcheckCustomDictionary::Change& dictionary_change) {
445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
446 if (!dictionary_change.to_add().empty()) { 446 if (!dictionary_change.to_add().empty()) {
447 words_.insert(dictionary_change.to_add().begin(), 447 words_.insert(dictionary_change.to_add().begin(),
448 dictionary_change.to_add().end()); 448 dictionary_change.to_add().end());
449 } 449 }
450 if (!dictionary_change.to_remove().empty()) { 450 if (!dictionary_change.to_remove().empty()) {
451 WordSet updated_words; 451 WordSet updated_words =
452 std::set_difference(words_.begin(), 452 base::STLSetDifference<WordSet>(words_,
453 words_.end(), 453 dictionary_change.to_remove());
454 dictionary_change.to_remove().begin(),
455 dictionary_change.to_remove().end(),
456 std::inserter(updated_words, updated_words.end()));
457 std::swap(words_, updated_words); 454 std::swap(words_, updated_words);
458 } 455 }
459 } 456 }
460 457
461 void SpellcheckCustomDictionary::Save( 458 void SpellcheckCustomDictionary::Save(
462 const SpellcheckCustomDictionary::Change& dictionary_change) { 459 const SpellcheckCustomDictionary::Change& dictionary_change) {
463 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 460 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
464 BrowserThread::PostTask( 461 BrowserThread::PostTask(
465 BrowserThread::FILE, 462 BrowserThread::FILE,
466 FROM_HERE, 463 FROM_HERE,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 527
531 void SpellcheckCustomDictionary::Notify( 528 void SpellcheckCustomDictionary::Notify(
532 const SpellcheckCustomDictionary::Change& dictionary_change) { 529 const SpellcheckCustomDictionary::Change& dictionary_change) {
533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
534 if (!IsLoaded() || dictionary_change.empty()) 531 if (!IsLoaded() || dictionary_change.empty())
535 return; 532 return;
536 FOR_EACH_OBSERVER(Observer, 533 FOR_EACH_OBSERVER(Observer,
537 observers_, 534 observers_,
538 OnCustomDictionaryChanged(dictionary_change)); 535 OnCustomDictionaryChanged(dictionary_change));
539 } 536 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698