Skip to content

Commit 21d994d

Browse files
committed
remove const cast
No need for this to be non const Signed-off-by: Rosen Penev <[email protected]>
1 parent 8dab519 commit 21d994d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/basicio.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ size_t RemoteIo::Impl::populateBlocks(size_t lowBlock, size_t highBlock) {
10421042
if (rcount == 0) {
10431043
throw Error(ErrorCode::kerErrorMessage, "Data By Range is empty. Please check the permission.");
10441044
}
1045-
auto source = reinterpret_cast<byte*>(const_cast<char*>(data.c_str()));
1045+
auto source = reinterpret_cast<const byte*>(data.c_str());
10461046
size_t remain = rcount;
10471047
size_t totalRead = 0;
10481048
size_t iBlock = (rcount == size_) ? 0 : lowBlock;
@@ -1078,7 +1078,7 @@ int RemoteIo::open() {
10781078
p_->size_ = data.length();
10791079
size_t nBlocks = (p_->size_ + p_->blockSize_ - 1) / p_->blockSize_;
10801080
p_->blocksMap_ = std::make_unique<BlockMap[]>(nBlocks);
1081-
auto source = reinterpret_cast<byte*>(const_cast<char*>(data.c_str()));
1081+
auto source = reinterpret_cast<const byte*>(data.c_str());
10821082
size_t remain = p_->size_;
10831083
size_t iBlock = 0;
10841084
size_t totalRead = 0;

src/crwimage_int.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,18 +472,18 @@ CiffComponent* CiffHeader::findComponent(uint16_t crwTagId, uint16_t crwDir) con
472472
return pRootDir_->findComponent(crwTagId, crwDir);
473473
} // CiffHeader::findComponent
474474

475-
CiffComponent* CiffComponent::findComponent(uint16_t crwTagId, uint16_t crwDir) const {
475+
CiffComponent* CiffComponent::findComponent(uint16_t crwTagId, uint16_t crwDir) {
476476
return doFindComponent(crwTagId, crwDir);
477477
} // CiffComponent::findComponent
478478

479-
CiffComponent* CiffComponent::doFindComponent(uint16_t crwTagId, uint16_t crwDir) const {
479+
CiffComponent* CiffComponent::doFindComponent(uint16_t crwTagId, uint16_t crwDir) {
480480
if (tagId() == crwTagId && dir() == crwDir) {
481-
return const_cast<CiffComponent*>(this);
481+
return this;
482482
}
483483
return nullptr;
484484
} // CiffComponent::doFindComponent
485485

486-
CiffComponent* CiffDirectory::doFindComponent(uint16_t crwTagId, uint16_t crwDir) const {
486+
CiffComponent* CiffDirectory::doFindComponent(uint16_t crwTagId, uint16_t crwDir) {
487487
for (auto&& component : components_) {
488488
if (auto cc = component->findComponent(crwTagId, crwDir))
489489
return cc;

src/crwimage_int.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class CiffComponent {
228228
@brief Finds \em crwTagId in directory \em crwDir, returning a pointer to
229229
the component or 0 if not found.
230230
*/
231-
[[nodiscard]] CiffComponent* findComponent(uint16_t crwTagId, uint16_t crwDir) const;
231+
[[nodiscard]] CiffComponent* findComponent(uint16_t crwTagId, uint16_t crwDir);
232232
//@}
233233

234234
protected:
@@ -263,7 +263,7 @@ class CiffComponent {
263263
//! Implements empty(). Default implementation returns true if size is 0.
264264
[[nodiscard]] virtual bool doEmpty() const;
265265
//! Implements findComponent(). The default implementation checks the entry.
266-
[[nodiscard]] virtual CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir) const;
266+
[[nodiscard]] virtual CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir);
267267
//@}
268268

269269
private:
@@ -360,7 +360,7 @@ class CiffDirectory : public CiffComponent {
360360
[[nodiscard]] bool doEmpty() const override;
361361

362362
// See base class comment
363-
[[nodiscard]] CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir) const override;
363+
[[nodiscard]] CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir) override;
364364
//@}
365365

366366
// DATA

0 commit comments

Comments
 (0)