Menu

#20 more efficiency and init fix

Unstable (example)
closed-out-of-date
nobody
None
5
2015-03-06
2013-05-30
NightOrion
No

In some places to check the object is void, you compare its size to zero. "size ()> 0" efficiency of a more could be used in such cases the "empty()"

json_writer.cpp
childValue.size() > 0 -> !childValue.empty()

json_value.cpp
value_.map_->size() == 0 -> value_.map_->empty()

also some init not correct

json_value.cpp

// class PathArgument
// //////////////////////////////////////////////////////////////////

PathArgument::PathArgument()
: key_() -> key_(NULL)
, index_() -> index_(0)
, kind_( kindNone )
{
}

PathArgument::PathArgument( ArrayIndex index )
: key_() -> key_(NULL)
, index_( index )
, kind_( kindIndex )
{
}

PathArgument::PathArgument( const char *key )
: key_( key )
, index_() -> index_(0)
, kind_( kindKey )
{
}

PathArgument::PathArgument( const std::string &key )
: key_( key.c_str() )
, index_() -> index_(0)
, kind_( kindKey )
{
}

json_reader.cpp

// Class Reader
// //////////////////////////////////////////////////////////////////

Reader::Reader()
: errors_(), -> need del (have his own constructor)
document_(), -> need del
begin_(), -> begin_(NULL)
end_(), -> end_(NULL)
current_(), -> current_(NULL)
lastValueEnd_(), -> lastValueEnd_(NULL)
lastValue_(), -> lastValue_(NULL)
commentsBefore_(), -> need del
features_( Features::all() ),
collectComments_() -> collectComments_(false)
{
}

Reader::Reader( const Features &features )
: errors_(), -> need del (have his own constructor)
document_(), -> need del
begin_(), -> begin_(NULL)
end_(), -> end_(NULL)
current_(), -> current_(NULL)
lastValueEnd_(), -> lastValueEnd_(NULL)
lastValue_(), -> lastValue_(NULL)
commentsBefore_(), -> need del
features_( features ),
collectComments_() -> collectComments_(false)
{
}

Discussion

  • Baptiste Lepilleur

    Could you attach either a patch file, or the modified files? This would be easier to review/merge.

     
  • NightOrion

    NightOrion - 2013-05-31

    Patch with modifications

     
  • Christopher Dunn

    Please double-check, and if needed, re-submit the patch, at: https://github.com/open-source-parsers/jsoncpp/issues

     
  • Christopher Dunn

    • status: open --> closed-out-of-date
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.