- Now that tizen supports c++20, we can use the new method 'starts_with' in std::string.
- It is fast(constexpr method) and simple.
Change-Id: I9b7b8ad91655d0cc268dff333d7f1b7e3af35440
Signed-off-by: pjh9216 <jh9216.park@samsung.com>
bool need_check = false;
int index;
- if (uri.compare(0, 1, "/") == 0) {
+ if (uri.starts_with("/")) {
if (mime.empty()) {
need_check = true;
index = 0;
}
- } else if (uri.compare(0, 8, "file:///") == 0) {
+ } else if (uri.starts_with("file:///")) {
if (mime.empty()) {
need_check = true;
index = 7;
}
- } else if (uri.compare(0, 6, "file:/") == 0) {
+ } else if (uri.starts_with("file:/")) {
if (mime.empty()) {
need_check = true;
index = 5;
std::string GetInterfaceName(const std::string& app_id,
const std::string& port_name, uid_t uid) {
- if (app_id.compare(0, strlen(kDPrefix), kDPrefix) == 0)
+ if (app_id.starts_with(kDPrefix))
return app_id + "::" + port_name;
- if (app_id.compare(0, strlen(kUdPrefix), kUdPrefix) == 0)
+ if (app_id.starts_with(kUdPrefix))
return std::to_string(uid) + "::" + app_id + "::" + port_name;
std::string name = kInterfacePrefix + app_id + "_" + port_name;
bool ResPkgInfo::IsGadget() const {
return (res_type_.length() > strlen(kGadgetPrefix) &&
- !res_type_.compare(0, strlen(kGadgetPrefix), kGadgetPrefix));
+ res_type_.starts_with(kGadgetPrefix));
}
bool ResPkgInfo::CheckAllowedPackage(