Skip to content

Commit 268745b

Browse files
committed
Minor improvements
1 parent 42ac2db commit 268745b

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

include/fastgltf/core.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ namespace fastgltf {
648648
[[nodiscard]] std::size_t totalSize() override;
649649

650650
[[nodiscard]] explicit operator std::span<std::byte>() const {
651-
return std::span(buffer.get(), dataSize);
651+
return {buffer.get(), dataSize};
652652
}
653653
};
654654

@@ -705,7 +705,7 @@ namespace fastgltf {
705705
[[nodiscard]] std::size_t totalSize() override;
706706

707707
[[nodiscard]] explicit operator std::span<std::byte>() const {
708-
return std::span(static_cast<std::byte*>(mappedFile), fileSize);
708+
return {static_cast<std::byte*>(mappedFile), fileSize};
709709
}
710710
};
711711
#endif

src/fastgltf.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ fg::Error fg::Parser::generateMeshIndices(fastgltf::Asset& asset) const {
930930

931931
fg::Error fg::validate(const Asset& asset) {
932932
auto isExtensionUsed = [&used = asset.extensionsUsed](const std::string_view extension) {
933-
return std::any_of(used.begin(), used.end(), [&](auto& arg) {
933+
return std::ranges::any_of(used, [&](auto& arg) {
934934
return arg == extension;
935935
});
936936
};
@@ -1517,7 +1517,7 @@ fg::Expected<fg::Asset> fg::Parser::parse(simdjson::dom::object root, Category c
15171517
}
15181518
}
15191519

1520-
Category readCategories = Category::None;
1520+
auto readCategories = Category::None;
15211521
for (const auto object : root) {
15221522
auto hashedKey = crcStringFunction(object.key);
15231523
if (hashedKey == force_consteval<crc32c("scene")>) {
@@ -1555,7 +1555,7 @@ fg::Expected<fg::Asset> fg::Parser::parse(simdjson::dom::object root, Category c
15551555
readCategories |= Category::name; \
15561556
break;
15571557

1558-
Error error = Error::None;
1558+
auto error = Error::None;
15591559
switch (hashedKey) {
15601560
KEY_SWITCH_CASE(Accessors, accessors)
15611561
KEY_SWITCH_CASE(Animations, animations)
@@ -2472,9 +2472,7 @@ fg::Error fg::Parser::parseImages(simdjson::dom::array& images, Asset& asset) {
24722472

24732473
std::string_view mimeType;
24742474
if (imageObject["mimeType"].get_string().get(mimeType) == SUCCESS) [[likely]] {
2475-
std::visit([&](auto& arg) {
2476-
using T = std::decay_t<decltype(arg)>;
2477-
2475+
std::visit([&]<typename T>(T& arg) {
24782476
// This is kinda cursed
24792477
if constexpr (is_any_of_v<T, sources::CustomBuffer, sources::BufferView, sources::URI, sources::Array, sources::Vector>) {
24802478
arg.mimeType = getMimeTypeFromString(mimeType);

src/io.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void fg::GltfDataBuffer::read(void *ptr, std::size_t count) {
9999
}
100100

101101
std::span<std::byte> fg::GltfDataBuffer::read(std::size_t count, [[maybe_unused]] std::size_t padding) {
102-
std::span<std::byte> sub(buffer.get() + idx, count);
102+
std::span sub(buffer.get() + idx, count);
103103
idx += count;
104104
return sub;
105105
}

0 commit comments

Comments
 (0)