#20 more efficiency and init fix

Unstable (example)
open
nobody
None
5
2013-05-31
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

  • 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

     
    Attachments