Skip to content

Commit

Permalink
w
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Feb 20, 2025
1 parent ab6208e commit a6b2eef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
15 changes: 0 additions & 15 deletions src/paramdict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,6 @@ int ParamDict::load_param(const DataReader& dr)
d->params[id].s = std::string(vstr);
}

#if NCNN_SIMPLESTL
// simple stl string has no tail zero by default, append one
int len = d->params[id].s.size();
d->params[id].s.resize(len + 1);
d->params[id].s[len] = '\0';
d->params[id].s.resize(len);
#endif

d->params[id].type = 7;

continue;
Expand Down Expand Up @@ -565,13 +557,6 @@ int ParamDict::load_param_bin(const DataReader& dr)

d->params[id].s = tmpstr.data();

#if NCNN_SIMPLESTL
// simple stl string has no tail zero by default, append one
d->params[id].s.resize(len + 1);
d->params[id].s[len] = '\0';
d->params[id].s.resize(len);
#endif

d->params[id].type = 7;
}
else if (is_array)
Expand Down
10 changes: 3 additions & 7 deletions src/simplestl.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,11 @@ struct NCNN_EXPORT string : public vector<char>
}
bool operator==(const string& str2) const
{
return strcmp(data_, str2.data_) == 0;
return size_ == str2.size_ && strncmp(data_, str2.data_, size_) == 0;
}
bool operator==(const char* str2) const
bool operator!=(const string& str2) const
{
return strcmp(data_, str2) == 0;
}
bool operator!=(const char* str2) const
{
return strcmp(data_, str2) != 0;
return size_ != str2.size_ || strncmp(data_, str2.data_, size_) != 0;
}
string& operator+=(const string& str1)
{
Expand Down

0 comments on commit a6b2eef

Please sign in to comment.