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

Cleanups #257

Merged
merged 9 commits into from
Dec 13, 2024
Merged

Cleanups #257

merged 9 commits into from
Dec 13, 2024

Conversation

kimkulling
Copy link
Owner

@kimkulling kimkulling commented Dec 13, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced console output for model loading statistics in the ModelLoading component.
  • Bug Fixes

    • Improved error handling for invalid command types in the TransformController.
  • Chores

    • Removed ZIP file handling capabilities from the project, including related classes and files.
    • Updated subproject commit references for cppcore and vcpkg.
  • Refactor

    • Streamlined the IOService class and TAsyncQueue class for better clarity and memory management.
  • Documentation

    • Updated comments and parameter names for clarity in the TAsyncQueue class.

Copy link

coderabbitai bot commented Dec 13, 2024

Walkthrough

The pull request introduces significant modifications to the OSRE project, focusing on the removal of the contrib/unzip directory and its associated files, which were responsible for ZIP file handling. Additionally, the CMakeLists.txt files across various directories have been updated to reflect these removals and to streamline the build configuration. Changes also include updates to the TAsyncQueue class for improved memory management and clarity. Overall, the changes indicate a shift away from ZIP file handling capabilities and a cleanup of the build process.

Changes

File Path Change Summary
CMakeLists.txt Removed contrib/unzip from INCLUDE_DIRECTORIES and ADD_SUBDIRECTORY. Retained OSRE_BUILD_DOC option. Set minimum CMake version to 3.5. Streamlined compiler flag handling. Added set_property(GLOBAL PROPERTY USE_FOLDERS ON).
contrib/cppcore Updated subproject commit reference.
contrib/unzip/CMakeLists.txt Deleted file; previously configured build settings for the Unzip library.
contrib/unzip/ChangeLogUnzip Deleted historical record of changes for the Unzip software.
contrib/unzip/crypt.h Deleted file; contained encryption/decryption functionalities for ZIP files.
contrib/unzip/ioapi.c Deleted file; provided file handling functions for zlib compression library.
contrib/unzip/ioapi.h Deleted header for IO base functions related to ZIP files.
contrib/unzip/unzip.c Deleted file; implemented functionality for reading and decompressing ZIP files.
contrib/unzip/unzip.h Deleted header file for handling extraction from ZIP archives.
contrib/vcpkg Updated subproject commit identifier.
samples/01_ModelLoading/ModelLoading.cpp Added <iostream> include; updated dumpNode and showStatistics methods for console output.
src/Engine/App/TransformController.cpp Added case for TransformCommandType::Invalid in update method; enhanced logging for invalid command types.
src/Engine/CMakeLists.txt Updated library version to "0.1.1". Removed ZIP-related source files from build configuration.
src/Engine/IO/IOService.cpp Removed createFS function; simplified logic in file system management methods.
src/Engine/IO/IOService.h Removed addFileSystem method from the IOService class.
src/Engine/IO/ZipFileStream.cpp Deleted file; provided functionality for reading files from ZIP archives.
src/Engine/IO/ZipFileStream.h Deleted header file for ZipFileStream class.
src/Engine/IO/ZipFileSystem.cpp Deleted file; managed ZIP file archives.
src/Engine/IO/ZipFileSystem.h Deleted header file for ZipFileSystem class.
src/Engine/Threading/TAsyncQueue.h Refactored member variables and method parameters for clarity; simplified memory management.

Possibly related PRs

  • Improvement/update deps and more #248: The changes in this PR involve updates to the CMakeLists.txt file, including setting the minimum required CMake version and adjusting project versioning, which aligns with the modifications made in the main PR regarding the CMakeLists.txt file.

🐰 In the meadow, changes bloom,
The ZIP files gone, make room!
CMake sings a clearer tune,
As rabbits hop beneath the moon.
With each update, we refine,
A project bright, a path divine! 🌙✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (6)
src/Engine/CMakeLists.txt (1)

Line range hint 8-14: Remove unused Unzip include directory

The contrib/unzip/ directory is still listed in INCLUDE_DIRECTORIES but the ZIP functionality has been removed from the project. This include path should be removed to maintain consistency with the changes.

Apply this diff to remove the unused include directory:

INCLUDE_DIRECTORIES(
    engine
    contrib/cppcore/include
    contrib/glew/include
    contrib/glm/
-   contrib/unzip/
    contrib/zlib/
    contrib/zlib/
    contrib/assimp/include
)
src/Engine/App/TransformController.cpp (2)

146-147: Consider adding logging for Invalid command type

While having an explicit case for Invalid is good practice, silently breaking might hide issues. Consider adding a warning log here to help with debugging when invalid commands occur.

 case TransformCommandType::Invalid:
+    osre_warn(Tag, "Received Invalid transform command");
     break;

Line range hint 141-144: Document why Z-axis transforms are ignored

The code explicitly ignores Z-axis transformations without explaining why. Consider adding a comment explaining the rationale behind this decision to help future maintainers.

         case TransformCommandType::TransformCommandZPositive:
         case TransformCommandType::TransformCommandZNegative:
-            // ignored
+            // Z-axis transforms are ignored because [add reason here]
             break;
src/Engine/IO/IOService.cpp (1)

Remove ZIP-related code remnants for consistency

There are still ZIP-related references that need to be cleaned up:

  • Zip_Extension constant in src/Engine/IO/IOService.cpp
  • ZIP extension registration in src/Engine/App/AssetBundle.h
  • ZIP-related test cases in test/UnitTests/src/App/AssetBundleTest.cpp
🔗 Analysis chain

Line range hint 31-31: Remove unused ZIP-related constant.

The Zip_Extension constant appears to be unused after the removal of ZIP file handling capabilities.

Let's verify if there are any remaining ZIP-related references that need cleanup:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining ZIP-related code
rg -i "zip|\.zip" --type cpp --type hpp --type h

Length of output: 78


Script:

#!/bin/bash
# Search for any remaining ZIP-related code with correct file extensions
rg -i "zip|\.zip" --type cpp --type h

# Also search for the specific constant name
rg "Zip_Extension" --type cpp --type h

# List all files to understand available extensions
fd -e cpp -e h -e hpp

Length of output: 13780

src/Engine/Threading/TAsyncQueue.h (2)

33-35: Fix typo and enhance thread-safety documentation

The class documentation has a typo ("thread-save" should be "thread-safe") and could benefit from more detailed thread-safety guarantees.

-///	@brief	This template class implements a thread-save queue.
+///	@brief	This template class implements a thread-safe queue.
+///
+/// This queue provides thread-safe operations through internal synchronization.
+/// All public methods are protected by a critical section, ensuring safe
+/// concurrent access from multiple threads.

88-91: Remove unnecessary empty comment

The "empty" comment doesn't add value and could be removed for better clarity.

 inline TAsyncQueue<T>::TAsyncQueue() :
         mCriticalSection(),
         mEnqueueEvent(),
-        mItemQueue() {
-    // empty
-}
+        mItemQueue() {
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d23ee05 and 9525042.

📒 Files selected for processing (20)
  • CMakeLists.txt (0 hunks)
  • contrib/cppcore (1 hunks)
  • contrib/unzip/CMakeLists.txt (0 hunks)
  • contrib/unzip/ChangeLogUnzip (0 hunks)
  • contrib/unzip/crypt.h (0 hunks)
  • contrib/unzip/ioapi.c (0 hunks)
  • contrib/unzip/ioapi.h (0 hunks)
  • contrib/unzip/unzip.c (0 hunks)
  • contrib/unzip/unzip.h (0 hunks)
  • contrib/vcpkg (1 hunks)
  • samples/01_ModelLoading/ModelLoading.cpp (1 hunks)
  • src/Engine/App/TransformController.cpp (1 hunks)
  • src/Engine/CMakeLists.txt (1 hunks)
  • src/Engine/IO/IOService.cpp (1 hunks)
  • src/Engine/IO/IOService.h (0 hunks)
  • src/Engine/IO/ZipFileStream.cpp (0 hunks)
  • src/Engine/IO/ZipFileStream.h (0 hunks)
  • src/Engine/IO/ZipFileSystem.cpp (0 hunks)
  • src/Engine/IO/ZipFileSystem.h (0 hunks)
  • src/Engine/Threading/TAsyncQueue.h (3 hunks)
💤 Files with no reviewable changes (13)
  • contrib/unzip/ChangeLogUnzip
  • src/Engine/IO/ZipFileSystem.h
  • src/Engine/IO/IOService.h
  • contrib/unzip/CMakeLists.txt
  • contrib/unzip/unzip.c
  • CMakeLists.txt
  • src/Engine/IO/ZipFileStream.cpp
  • contrib/unzip/unzip.h
  • contrib/unzip/ioapi.h
  • contrib/unzip/ioapi.c
  • src/Engine/IO/ZipFileStream.h
  • contrib/unzip/crypt.h
  • src/Engine/IO/ZipFileSystem.cpp
✅ Files skipped from review due to trivial changes (2)
  • contrib/cppcore
  • contrib/vcpkg
🔇 Additional comments (7)
src/Engine/CMakeLists.txt (1)

457-457: LGTM: Library dependencies updated correctly

The removal of the Unzip library from target_link_libraries is consistent with the removal of ZIP functionality from the project.

src/Engine/IO/IOService.cpp (2)

87-89: LGTM! Good modernization of pointer handling.

The changes improve code clarity by:

  • Using modern C++ nullptr instead of NULL
  • Making the null check more explicit

109-109: LGTM! Good optimization.

The added empty check for mMountedMap is a nice optimization that avoids unnecessary map lookup operations.

samples/01_ModelLoading/ModelLoading.cpp (2)

35-36: LGTM! Include placement follows best practices.

The addition of <iostream> is properly placed after system/project includes and is necessary for the std::cout usage in the output methods.


35-36: Verify model loading compatibility after ZIP removal.

Given the removal of ZIP file handling capabilities mentioned in the PR summary, we should verify that model loading still works correctly for all supported formats.

✅ Verification successful

Let me gather more information about the model loading functionality to make a proper assessment.


Based on the gathered information, I can now provide a final response:

Model loading remains fully functional despite ZIP removal

The codebase shows that model loading is primarily handled through Assimp and doesn't depend on ZIP functionality. The AssimpWrapper implementation uses direct file loading with proper import flags (aiProcess_*) and supports all Assimp-compatible formats. The only ZIP-related code found is in the asset bundle system, which is separate from the core model loading functionality.

Key findings:

  • Model loading is implemented in AssimpWrapper with standard Assimp import flags
  • Direct file loading is used via Uri system
  • ZIP support was only used in asset bundling, not in model loading
  • All core model loading tests and functionality remain intact
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining ZIP-related functionality or test cases
rg -i "zip|\.zip" --type cpp --type h

# Look for supported file formats in Assimp wrapper
ast-grep --pattern 'importAsset($_, $_) {
  $$$
}'

Length of output: 381


Script:

#!/bin/bash
# Check model loading implementation and supported formats
rg -A 10 "loadAsset|importAsset|LoadModel" --type cpp

# Look for Assimp initialization and format configurations
rg -i "assimp|aiProcess|aiScene" --type cpp --type h

# Check for any model loading tests
fd "test.*\.(cpp|h)$" --exec rg -l "Model|Asset.*Load"

Length of output: 13849

src/Engine/Threading/TAsyncQueue.h (2)

81-83: Excellent improvement in memory management

Converting pointer members to direct instances is a great improvement that:

  • Eliminates potential memory leaks
  • Follows RAII principles
  • Reduces complexity
  • Improves exception safety

145-147: LGTM: Utility methods are thread-safe and well-implemented

The size, isEmpty, and clear methods are correctly protected by critical sections and implement their functionality appropriately.

Also applies to: 161-163, 170-174

src/Engine/App/TransformController.cpp Outdated Show resolved Hide resolved
src/Engine/IO/IOService.cpp Outdated Show resolved Hide resolved
src/Engine/Threading/TAsyncQueue.h Outdated Show resolved Hide resolved
src/Engine/Threading/TAsyncQueue.h Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
src/Engine/IO/IOService.cpp (2)

98-98: Fix typo in error message.

There's a typo in the error message: "Incalid" should be "Invalid".

-        osre_error(Tag, "Incalid stream.");
+        osre_error(Tag, "Invalid stream.");

82-110: Consider documenting the removal of ZIP functionality.

Given that these changes are part of a larger cleanup removing ZIP functionality, it would be helpful to:

  1. Add a comment in the header file documenting the supported file systems
  2. Update any relevant documentation about supported file formats
  3. Consider adding migration guides if this is a breaking change for users

This will help maintain clear documentation of the system's capabilities.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1a6405 and 68e636f.

📒 Files selected for processing (2)
  • src/Engine/IO/IOService.cpp (1 hunks)
  • src/Engine/Threading/TAsyncQueue.h (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Engine/Threading/TAsyncQueue.h
🔇 Additional comments (4)
src/Engine/IO/IOService.cpp (4)

82-84: LGTM! Improved pointer initialization and null check clarity.

The changes improve code readability with explicit nullptr initialization and clearer null checking syntax.


92-98: Improved error handling with proper null checks.

The addition of explicit null checks with error logging enhances the robustness of the code.


104-104: LGTM! Consistent null check style.

The null check follows the same explicit style used throughout the file.


110-110: LGTM! Good performance optimization.

The addition of the empty check prevents unnecessary map lookup operations when no file systems are mounted.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
src/Engine/IO/IOService.cpp (2)

91-103: Fix typo in error message and verify null checks.

The error handling is well-implemented, but there's a typo in the error message ("Incalid" should be "Invalid").

Here's the fix:

     if (nullptr == *ppStream) {
-        osre_error(Tag, "Incalid stream.");
+        osre_error(Tag, "Invalid stream.");
         return;
     }

37-37: Consider adding RAII-based resource management.

While the current implementation is functional, consider these architectural improvements:

  1. Use smart pointers for filesystem management to prevent memory leaks
  2. Consider adding a filesystem factory for better extensibility
  3. Add logging for successful operations to aid in debugging

Example implementation using smart pointers:

using FileSystemPtr = std::unique_ptr<AbstractFileSystem>;
using MountedMap = std::unordered_map<String, FileSystemPtr>;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68e636f and c22e272.

📒 Files selected for processing (1)
  • src/Engine/IO/IOService.cpp (2 hunks)
🔇 Additional comments (3)
src/Engine/IO/IOService.cpp (3)

35-37: LGTM! Good use of constexpr for the tag.

The constant definition and constructor initialization are well-implemented.


109-109: LGTM! Good optimization.

The empty check before searching the map is a good optimization.


81-87: ⚠️ Potential issue

Remove unused variable and simplify the code.

The pStream variable is declared but never used, as flagged by static analysis.

Here's the suggested fix:

 Stream *IOService::openStream(const Uri &file, Stream::AccessMode mode) {
-    Stream *pStream = nullptr;
     if (AbstractFileSystem *fs = getFileSystem(file.getScheme()); fs != nullptr) {
         return fs->open( file, mode );
     }
     return nullptr;
 }

Likely invalid or redundant comment.

src/Engine/IO/IOService.cpp Show resolved Hide resolved
Comment on lines +71 to +76
void IOService::umountFileSystem( const String &schema, AbstractFileSystem *fileSystem ) {
MountedMap::iterator it = mMountedMap.find(schema);
if ( mMountedMap.end() == it ) {
return;
}
if (it->second == pFileSystem) {
if (it->second == fileSystem) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add parameter validation and error logging.

While the unmounting logic is correct, it should validate the input parameter and provide feedback when the filesystem isn't found.

Here's the suggested improvement:

 void IOService::umountFileSystem( const String &schema, AbstractFileSystem *fileSystem ) {
+    if (fileSystem == nullptr) {
+        osre_error(Tag, "Null filesystem provided");
+        return;
+    }
     MountedMap::iterator it = mMountedMap.find(schema);
     if ( mMountedMap.end() == it ) {
+        osre_debug(Tag, "No filesystem mounted for schema: " + schema);
         return;
     }
     if (it->second == fileSystem) {
         mMountedMap.erase(it);
+    } else {
+        osre_debug(Tag, "Filesystem mismatch for schema: " + schema);
     }
 }

Committable suggestion skipped: line range outside the PR's diff.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
src/Engine/IO/IOService.cpp (4)

81-86: Add error logging for failed filesystem lookup.

While the error handling is correct, adding logging would help with debugging when a filesystem for the given scheme is not found.

 Stream *IOService::openStream(const Uri &file, Stream::AccessMode mode) {
     if (AbstractFileSystem *fs = getFileSystem(file.getScheme()); fs != nullptr) {
         return fs->open( file, mode );
     }
 
+    osre_debug(Tag, "No filesystem found for scheme: " + file.getScheme());
     return nullptr;
 }

96-96: Fix typo in error message.

There's a typo in the error message: "Incalid" should be "Invalid".

-        osre_error(Tag, "Incalid stream.");
+        osre_error(Tag, "Invalid stream.");

90-102: Add logging for filesystem lookup failure.

When closing a stream, we should log an error if we can't find the corresponding filesystem.

     const String &schema( (*ppStream)->getUri().getScheme() );
     AbstractFileSystem *pFS = getFileSystem( schema );
     if (pFS != nullptr) {
         pFS->close( ppStream );
+    } else {
+        osre_error(Tag, "No filesystem found for scheme: " + schema);
     }

35-35: Consider standardizing error handling patterns.

While error logging has been improved, consider creating a consistent pattern for error handling across all methods:

  1. Input validation with appropriate error logging
  2. Operation-specific error logging
  3. Standard error return values or exceptions

This will make the code more maintainable and debugging easier.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c22e272 and e5f4b67.

📒 Files selected for processing (1)
  • src/Engine/IO/IOService.cpp (3 hunks)
🔇 Additional comments (3)
src/Engine/IO/IOService.cpp (3)

121-124: LGTM!

The implementation is clean, with proper null checking and const correctness.


67-68: ⚠️ Potential issue

Add null pointer validation.

The method should validate the fileSystem parameter before storing it in the map to prevent potential null pointer issues.

 void IOService::mountFileSystem( const String &schema, AbstractFileSystem *fileSystem ) {
+    if (fileSystem == nullptr) {
+        osre_error(Tag, "Null filesystem provided");
+        return;
+    }
     mMountedMap[ schema ] = fileSystem;
 }

40-40: Review commented-out filesystem initialization.

The commented line suggests that the default filesystem initialization was intentionally disabled. This could lead to issues if code expects a "file" schema handler to be available by default.

Let's check if there are any dependencies on the "file" schema:

✅ Verification successful

The commented-out code is safe to remove as filesystem initialization is properly handled elsewhere

The commented line can be safely removed because:

  1. The LocaleFileSystem is properly initialized in IOService::onOpen() where it's created and mounted using mountFileSystem(pFileSystem->getSchema(), pFileSystem).
  2. The "file" schema is consistently used throughout the codebase and its initialization is not dependent on the commented line.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of "file" schema across the codebase
rg -l '"file".*getSchema|getScheme'

Length of output: 142


Script:

#!/bin/bash
# Let's check the actual usage context of "file" schema in these files
rg '"file".*getSchema|getScheme' -A 3 -B 3

# Also check for any direct usage of LocaleFileSystem
rg "LocaleFileSystem" -A 3 -B 3

# Check if there are any other places where filesystems are mounted
ast-grep --pattern 'mMountedMap[$_] = $_'

Length of output: 8679

}

IOService::IOService() : AbstractService( "io/ioserver" ), mMountedMap() {
IOService::IOService() : AbstractService("io/ioserver"), mMountedMap() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using smart pointers for better memory management.

The current implementation uses raw pointers for both file systems and streams. Consider using std::unique_ptr for clearer ownership semantics and automatic resource cleanup.

Example refactoring:

using FileSystemPtr = std::unique_ptr<AbstractFileSystem>;
using MountedMap = std::unordered_map<String, FileSystemPtr>;

This would eliminate the need for manual deletion in onClose() and prevent potential memory leaks.

CREATE_SINGLETON( IOService );

mMountedMap["file"] = new LocaleFileSystem();
// mMountedMap["file"] = new LocaleFileSystem();

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
@kimkulling kimkulling merged commit e8b0d93 into master Dec 13, 2024
5 checks passed
@kimkulling kimkulling deleted the feature/cleanup_io_system branch December 13, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants