Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Jul 25, 2019
1 parent b7b56f2 commit fc37c9f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
12 changes: 5 additions & 7 deletions include/xgboost/json_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class JsonReader {

public:
SourceLocation() : pos_(0) {}
SourceLocation(size_t pos) : pos_{pos} {}
size_t Pos() const { return pos_; }

SourceLocation& Forward(char c = 0) {
Expand Down Expand Up @@ -138,20 +139,17 @@ class JsonReader {

Json Parse();

void SetStr(StringView const& str) {
raw_str_ = str;
}
void SetCursor(size_t pos) {
cursor_.pos_ = pos;
}

private:
using Fn = std::function<Json (StringView, size_t*)>;

public:
explicit JsonReader(StringView str, bool ignore = false) :
raw_str_{str},
ignore_specialization_{ignore} {}
explicit JsonReader(StringView str, size_t pos, bool ignore = false) :
cursor_{pos},
raw_str_{str},
ignore_specialization_{ignore} {}

virtual ~JsonReader() = default;

Expand Down
1 change: 1 addition & 0 deletions src/common/json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
#include <sstream>

#include "charconv.h"
#include "xgboost/logging.h"
#include "xgboost/json.h"
#include "xgboost/json_io.h"
Expand Down
4 changes: 1 addition & 3 deletions src/gbm/gblinear_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ class LinearSelectRaw : public JsonReader {

public:
LinearSelectRaw(StringView str, size_t* pos) :
JsonReader{str}, pre_pos_{pos} {
JsonReader::SetCursor(*pos);
}
JsonReader{str, *pos}, pre_pos_{pos} {}

Json ParseRaw() {
SkipSpaces();
Expand Down
4 changes: 1 addition & 3 deletions src/gbm/gbtree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,7 @@ class TreeSelectRaw : public JsonReader {

public:
TreeSelectRaw(StringView str, size_t* pos) :
JsonReader{str}, pre_pos_{pos} {
JsonReader::SetCursor(*pos);
}
JsonReader{str, *pos}, pre_pos_{pos} {}

Json ParseRaw() {
SkipSpaces();
Expand Down

0 comments on commit fc37c9f

Please sign in to comment.