refactor: fix modernize-return-braced-init-list warnings (#44838)

* refactor: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]

* refactor: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]

NB: using the braced-initializer list uncovered an error here:
the float returned by std::floor() can't be implicitly cast to
an int. This is solved by using base::ClampFloor<int>() instead.
std::floor()
This commit is contained in:
Charles Kerr 2024-11-26 18:41:46 -06:00 committed by GitHub
parent 9f1e23c405
commit f595443a22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 79 additions and 81 deletions

View file

@ -323,7 +323,7 @@ gfx::Size NativeImage::GetSize(const std::optional<float> scale_factor) {
float sf = scale_factor.value_or(1.0f);
gfx::ImageSkiaRep image_rep = image_.AsImageSkia().GetRepresentation(sf);
return gfx::Size(image_rep.GetWidth(), image_rep.GetHeight());
return {image_rep.GetWidth(), image_rep.GetHeight()};
}
std::vector<float> NativeImage::GetScaleFactors() {
@ -489,7 +489,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
const gin_helper::Dictionary& options) {
if (!node::Buffer::HasInstance(buffer)) {
thrower.ThrowError("buffer must be a node Buffer");
return gin::Handle<NativeImage>();
return {};
}
int width = 0;
@ -497,12 +497,12 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
if (!options.Get("width", &width)) {
thrower.ThrowError("width is required");
return gin::Handle<NativeImage>();
return {};
}
if (!options.Get("height", &height)) {
thrower.ThrowError("height is required");
return gin::Handle<NativeImage>();
return {};
}
if (width <= 0 || height <= 0)
@ -514,7 +514,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
const auto buffer_data = electron::util::as_byte_span(buffer);
if (size_bytes != buffer_data.size()) {
thrower.ThrowError("invalid buffer size");
return gin::Handle<NativeImage>();
return {};
}
SkBitmap bitmap;
@ -536,7 +536,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBuffer(
gin::Arguments* args) {
if (!node::Buffer::HasInstance(buffer)) {
thrower.ThrowError("buffer must be a node Buffer");
return gin::Handle<NativeImage>();
return {};
}
int width = 0;