Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace const std::string& with StringView #550

Merged
merged 2 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/vcpkg/base/downloads.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace vcpkg
}

void verify_downloaded_file_hash(const Filesystem& fs,
const std::string& sanitized_url,
StringView sanitized_url,
const Path& downloaded_path,
const std::string& sha512);
StringView sha512);

View<std::string> azure_blob_headers();

Expand Down
4 changes: 2 additions & 2 deletions include/vcpkg/binarycaching.private.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ namespace vcpkg
};

inline NugetReference make_nugetref(const PackageSpec& spec,
const std::string& raw_version,
const std::string& abi_tag,
StringView raw_version,
StringView abi_tag,
const std::string& prefix)
{
return {Strings::concat(prefix, spec.dir()), format_version_for_nugetref(raw_version, abi_tag)};
Expand Down
2 changes: 1 addition & 1 deletion include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ namespace vcpkg::Build
STATIC,
};

Optional<LinkageType> to_linkage_type(const std::string& str);
Optional<LinkageType> to_linkage_type(StringView str);

struct BuildInfo
{
Expand Down
2 changes: 1 addition & 1 deletion include/vcpkg/sourceparagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace vcpkg
std::vector<std::unique_ptr<FeatureParagraph>> feature_paragraphs;
Json::Object extra_features_info;

Optional<const FeatureParagraph&> find_feature(const std::string& featurename) const;
Optional<const FeatureParagraph&> find_feature(StringView featurename) const;
Optional<const std::vector<Dependency>&> find_dependencies_for_feature(const std::string& featurename) const;
bool has_qualified_dependencies() const;

Expand Down
2 changes: 1 addition & 1 deletion include/vcpkg/spdx.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ namespace vcpkg
std::string document_namespace,
std::vector<Json::Value>&& resource_docs);

Json::Value run_resource_heuristics(const std::string& contents);
Json::Value run_resource_heuristics(StringView contents);
}
2 changes: 1 addition & 1 deletion include/vcpkg/vcpkglib.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ namespace vcpkg
const InstalledPaths& installed,
const StatusParagraphs& status_db);

std::string shorten_text(const std::string& desc, const size_t length);
std::string shorten_text(StringView desc, const size_t length);
} // namespace vcpkg
4 changes: 2 additions & 2 deletions include/vcpkg/vcpkgpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace vcpkg

Path package_dir(const PackageSpec& spec) const;
Path build_dir(const PackageSpec& spec) const;
Path build_dir(const std::string& package_name) const;
Path build_dir(StringView package_name) const;
Path build_info_file_path(const PackageSpec& spec) const;
Path spdx_resource_dir(const PackageSpec& spec) const;

Expand Down Expand Up @@ -139,7 +139,7 @@ namespace vcpkg
ExpectedS<std::string> get_current_git_sha() const;
std::string get_current_git_sha_baseline_message() const;
ExpectedS<Path> git_checkout_port(StringView port_name, StringView git_tree, const Path& dot_git_dir) const;
ExpectedS<std::string> git_show(const std::string& treeish, const Path& dot_git_dir) const;
ExpectedS<std::string> git_show(StringView treeish, const Path& dot_git_dir) const;

const DownloadManager& get_download_manager() const;

Expand Down
2 changes: 1 addition & 1 deletion include/vcpkg/versiondeserializers.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace vcpkg

void serialize_schemed_version(Json::Object& out_obj,
VersionScheme scheme,
const std::string& version,
StringView version,
int port_version,
bool always_emit_port_version = false);
}
4 changes: 2 additions & 2 deletions src/vcpkg/base/downloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ namespace vcpkg
}

void verify_downloaded_file_hash(const Filesystem& fs,
const std::string& url,
StringView url,
const Path& downloaded_path,
const std::string& sha512)
StringView sha512)
{
auto maybe_error = try_verify_downloaded_file_hash(fs, url, downloaded_path, sha512);
if (auto err = maybe_error.get())
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ namespace vcpkg::Build
}
}

Optional<LinkageType> to_linkage_type(const std::string& str)
Optional<LinkageType> to_linkage_type(StringView str)
{
if (str == "dynamic") return LinkageType::DYNAMIC;
if (str == "static") return LinkageType::STATIC;
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/sourceparagraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ namespace vcpkg
}
}

Optional<const FeatureParagraph&> SourceControlFile::find_feature(const std::string& featurename) const
Optional<const FeatureParagraph&> SourceControlFile::find_feature(StringView featurename) const
{
auto it = Util::find_if(feature_paragraphs,
[&](const std::unique_ptr<FeatureParagraph>& p) { return p->name == featurename; });
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/spdx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static Json::Object make_resource(
return obj;
}

Json::Value vcpkg::run_resource_heuristics(const std::string& contents)
Json::Value vcpkg::run_resource_heuristics(StringView contents)
{
// These are a sequence of heuristics to enable proof-of-concept extraction of remote resources for SPDX SBOM
// inclusion
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/vcpkglib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace vcpkg
return installed_files;
}

std::string shorten_text(const std::string& desc, const size_t length)
std::string shorten_text(StringView desc, const size_t length)
{
Checks::check_exit(VCPKG_LINE_INFO, length >= 3);
std::string simple_desc;
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/vcpkgpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ namespace vcpkg

Path VcpkgPaths::package_dir(const PackageSpec& spec) const { return this->packages() / spec.dir(); }
Path VcpkgPaths::build_dir(const PackageSpec& spec) const { return this->buildtrees() / spec.name(); }
Path VcpkgPaths::build_dir(const std::string& package_name) const { return this->buildtrees() / package_name; }
Path VcpkgPaths::build_dir(StringView package_name) const { return this->buildtrees() / package_name.data(); }

Path VcpkgPaths::build_info_file_path(const PackageSpec& spec) const
{
Expand Down Expand Up @@ -1007,7 +1007,7 @@ namespace vcpkg
}
}

ExpectedS<std::string> VcpkgPaths::git_show(const std::string& treeish, const Path& dot_git_dir) const
ExpectedS<std::string> VcpkgPaths::git_show(StringView treeish, const Path& dot_git_dir) const
{
// All git commands are run with: --git-dir={dot_git_dir} --work-tree={work_tree_temp}
// git clone --no-checkout --local {vcpkg_root} {dot_git_dir}
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/versiondeserializers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ namespace vcpkg

void serialize_schemed_version(Json::Object& out_obj,
VersionScheme scheme,
const std::string& version,
StringView version,
int port_version,
bool always_emit_port_version)
{
Expand Down