Skip to content

perf: Skip constructing unnecessary std::string#932

Merged
ngxson merged 1 commit intocrosspoint-reader:masterfrom
znelson:em-space
Feb 16, 2026
Merged

perf: Skip constructing unnecessary std::string#932
ngxson merged 1 commit intocrosspoint-reader:masterfrom
znelson:em-space

Conversation

@znelson
Copy link
Contributor

@znelson znelson commented Feb 16, 2026

Summary

What is the goal of this PR?

Skip constructing a std::string just to get the underlying c_str() buffer, when a string literal gives the same end result.


AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? NO

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 16, 2026

No actionable comments were generated in the recent review. 🎉

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6f38d4 and 9c0bc68.

📒 Files selected for processing (1)
  • lib/Epub/Epub/blocks/TextBlock.cpp
🔇 Additional comments (1)
lib/Epub/Epub/blocks/TextBlock.cpp (1)

32-37: Good micro-optimization.

Using a string literal here avoids an unnecessary temporary without changing behavior.


📝 Walkthrough

Walkthrough

A minor optimization in TextBlock where a string construction for computing text advance width is replaced with a direct string literal for the em-space character. The functionality remains equivalent while reducing temporary object allocation.

Changes

Cohort / File(s) Summary
TextBlock Optimization
lib/Epub/Epub/blocks/TextBlock.cpp
Replaced renderer.getTextAdvanceX call with temporary std::string construction with direct string literal usage for em-space character prefix, eliminating unnecessary string object instantiation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: skipping unnecessary std::string construction for a performance optimization in the TextBlock.cpp file.
Description check ✅ Passed The description clearly explains the goal (avoiding unnecessary std::string construction), provides context about the change, and is directly related to the changeset modifications.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@znelson znelson marked this pull request as ready for review February 16, 2026 16:41
@ngxson ngxson merged commit 97c3314 into crosspoint-reader:master Feb 16, 2026
8 checks passed
@znelson znelson deleted the em-space branch February 17, 2026 02:00
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
## Summary

**What is the goal of this PR?**

Skip constructing a `std::string` just to get the underlying `c_str()`
buffer, when a string literal gives the same end result.

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_
lukestein pushed a commit to lukestein/crosspoint-reader that referenced this pull request Feb 18, 2026
## Summary

**What is the goal of this PR?**

Skip constructing a `std::string` just to get the underlying `c_str()`
buffer, when a string literal gives the same end result.

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_
ariel-lindemann pushed a commit to ariel-lindemann/crosspoint-reader that referenced this pull request Feb 19, 2026
## Summary

**What is the goal of this PR?**

Skip constructing a `std::string` just to get the underlying `c_str()`
buffer, when a string literal gives the same end result.

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_
saslv pushed a commit to saslv/crosspoint-reader that referenced this pull request Feb 19, 2026
## Summary

**What is the goal of this PR?**

Skip constructing a `std::string` just to get the underlying `c_str()`
buffer, when a string literal gives the same end result.

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_
el pushed a commit to el/crosspoint-reader that referenced this pull request Feb 19, 2026
## Summary

**What is the goal of this PR?**

Skip constructing a `std::string` just to get the underlying `c_str()`
buffer, when a string literal gives the same end result.

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_
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.

4 participants