From 922efe43ed98e0e7117918ba102405c36e25a428 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Thu, 28 Feb 2013 17:40:24 +0000 Subject: [PATCH] Simplify line editor choice in d8. R=rossberg@chromium.org BUG= Review URL: https://chromiumcodereview.appspot.com/12330171 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13782 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/d8.cc | 20 +++----------------- src/d8.h | 5 ++--- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/d8.cc b/src/d8.cc index 3ef0d54..2d30a1c 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -123,26 +123,12 @@ class Symbols { }; -LineEditor *LineEditor::first_ = NULL; +LineEditor *LineEditor::current_ = NULL; LineEditor::LineEditor(Type type, const char* name) - : type_(type), - name_(name), - next_(first_) { - first_ = this; -} - - -LineEditor* LineEditor::Get() { - LineEditor* current = first_; - LineEditor* best = current; - while (current != NULL) { - if (current->type_ > best->type_) - best = current; - current = current->next_; - } - return best; + : type_(type), name_(name) { + if (current_ == NULL || current_->type_ < type) current_ = this; } diff --git a/src/d8.h b/src/d8.h index 1c3ce0a..f3b3fa1 100644 --- a/src/d8.h +++ b/src/d8.h @@ -128,12 +128,11 @@ class LineEditor { virtual void AddHistory(const char* str) { } const char* name() { return name_; } - static LineEditor* Get(); + static LineEditor* Get() { return current_; } private: Type type_; const char* name_; - LineEditor* next_; - static LineEditor* first_; + static LineEditor* current_; }; -- 2.7.4