facebook / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
28.39k stars 6.29k forks source link

Use `std::optional` instead of `std::unique_ptr` to conditionally create a read lock. #12704

Closed aractnido closed 4 months ago

aractnido commented 4 months ago

This change replaces the use of std::unique_ptr with std::optional for conditionally constructing a ReadLock object. The read lock object was recently introduced in PR #12624. This change makes the code more concise and clarifies that the lock is not meant to be transferred (as std::unique_ptr is movable). It also avoids a heap allocation.

There are no functional changes.

facebook-github-bot commented 4 months ago

@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 4 months ago

@ajkr merged this pull request in facebook/rocksdb@7c6c632ea982c5d59e02b433f99f778b9623e910.