Skip to content

Conversation

@adcondev
Copy link
Owner

Refactored MonochromeBitmap to cache the bytesPerRow calculation in a private field. This removes duplicated calculations in SetPixel, GetPixel, ToImage and GetWidthBytes, improving maintainability and slightly optimizing performance.

Changes:

  • Added bytesPerRow field to MonochromeBitmap struct.
  • Updated NewMonochromeBitmap to initialize bytesPerRow.
  • Updated SetPixel, GetPixel, GetWidthBytes, and ToImage to use the cached bytesPerRow.

PR created automatically by Jules for task 17139310501292623649 started by @adcondev

Cached the bytesPerRow calculation in MonochromeBitmap struct to avoid duplicated calculations and improve maintainability. Updated NewMonochromeBitmap to initialize the field and other methods to use it.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions
Copy link
Contributor

👋 Thanks for opening this PR, @adcondev!

Here's what will happen next:

  • 🤖 Automated checks will run
  • 🏷️ Labels will be added automatically
  • 👀 A maintainer will review your changes

Please make sure:

  • ✅ All tests pass
  • 📝 The PR title follows conventional commits
  • 📋 The PR template is filled out completely

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

⚡ Benchmark Results

📈 Performance Comparison

📊 Click to expand detailed results

Current Branch Results

BenchmarkNewDocument-4    	1000000000	         0.3120 ns/op	       0 B/op	       0 allocs/op
BenchmarkBuildSimple-4    	 3727083	       324.7 ns/op	     240 B/op	       4 allocs/op
BenchmarkBuildComplex-4   	  429243	      2708 ns/op	    1809 B/op	      25 allocs/op
BenchmarkToJSON-4         	  540000	      2080 ns/op	     592 B/op	       3 allocs/op
BenchmarkParseDocument_Minimal-4    	  516660	      2352 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Receipt-4    	   91740	     12619 ns/op	    2392 B/op	      34 allocs/op
BenchmarkCommandUnmarshal_Text-4    	  425286	      2675 ns/op	     568 B/op	      19 allocs/op
BenchmarkCommandUnmarshal_Table-4   	  274526	      4190 ns/op	     944 B/op	      21 allocs/op
BenchmarkTextCommandParsing-4       	  530343	      2106 ns/op	     544 B/op	      16 allocs/op
BenchmarkTableCommandParsing-4      	  239698	      4774 ns/op	    1000 B/op	      29 allocs/op
BenchmarkParseHexString-4           	 7363257	       154.3 ns/op	      48 B/op	       2 allocs/op
BenchmarkCleanHexString-4           	 6494617	       183.6 ns/op	      64 B/op	       2 allocs/op
BenchmarkContainsSequence-4         	295683699	         4.053 ns/op	       0 B/op	       0 allocs/op
BenchmarkCheckCriticalCommands-4    	33236622	        37.28 ns/op	       0 B/op	       0 allocs/op
BenchmarkDocument_Validate-4       	14550812	        82.82 ns/op	       0 B/op	       0 allocs/op
BenchmarkParseDocument_Simple-4    	  498999	      2386 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Complex-4   	  139711	      8450 ns/op	    1352 B/op	      26 allocs/op
BenchmarkPrintImage_Small-4             	     612	   1979819 ns/op	 3469938 B/op	      24 allocs/op
BenchmarkPrintImage_Medium-4            	     324	   3673105 ns/op	 5481087 B/op	      24 allocs/op
BenchmarkPrintImage_ThermalPreview-4    	     138	   8734235 ns/op	 5231183 B/op	  230423 allocs/op

Base Branch Results

BenchmarkNewDocument-4    	1000000000	         0.3117 ns/op	       0 B/op	       0 allocs/op
BenchmarkBuildSimple-4    	 3490863	       329.9 ns/op	     240 B/op	       4 allocs/op
BenchmarkBuildComplex-4   	  419557	      2721 ns/op	    1809 B/op	      25 allocs/op
BenchmarkToJSON-4         	  526819	      2111 ns/op	     592 B/op	       3 allocs/op
BenchmarkParseDocument_Minimal-4    	  513639	      2326 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Receipt-4    	   92798	     12711 ns/op	    2392 B/op	      34 allocs/op
BenchmarkCommandUnmarshal_Text-4    	  416108	      2728 ns/op	     568 B/op	      19 allocs/op
BenchmarkCommandUnmarshal_Table-4   	  278568	      4162 ns/op	     944 B/op	      21 allocs/op
BenchmarkTextCommandParsing-4       	  518899	      2097 ns/op	     544 B/op	      16 allocs/op
BenchmarkTableCommandParsing-4      	  246740	      4769 ns/op	    1000 B/op	      29 allocs/op
BenchmarkParseHexString-4           	 8633444	       135.2 ns/op	      48 B/op	       2 allocs/op
BenchmarkCleanHexString-4           	 6626664	       182.8 ns/op	      64 B/op	       2 allocs/op
BenchmarkContainsSequence-4         	365941700	         3.248 ns/op	       0 B/op	       0 allocs/op
BenchmarkCheckCriticalCommands-4    	36050787	        34.47 ns/op	       0 B/op	       0 allocs/op
BenchmarkDocument_Validate-4       	14507847	        82.69 ns/op	       0 B/op	       0 allocs/op
BenchmarkParseDocument_Simple-4    	  503178	      2390 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Complex-4   	  138735	      8496 ns/op	    1352 B/op	      26 allocs/op
BenchmarkPrintImage_Small-4             	     626	   1922854 ns/op	 3469937 B/op	      24 allocs/op
BenchmarkPrintImage_Medium-4            	     331	   3557589 ns/op	 5481086 B/op	      24 allocs/op
BenchmarkPrintImage_ThermalPreview-4    	     133	   8548054 ns/op	 5231183 B/op	  230423 allocs/op

💡 Note: Use benchstat for statistical comparison

🎯 Summary

  • Total Benchmarks: 32
  • Average Speed: 2605084 ns/op
  • Average Memory: 2396764 B/op
  • Average Allocations: 41077 allocs/op

@adcondev adcondev marked this pull request as ready for review February 12, 2026 21:01
Copilot AI review requested due to automatic review settings February 12, 2026 21:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the MonochromeBitmap struct to cache the bytesPerRow calculation, eliminating redundant computations and improving code maintainability.

Changes:

  • Added a bytesPerRow field to cache the (Width + 7) / 8 calculation
  • Updated NewMonochromeBitmap to initialize the cached field
  • Modified SetPixel, GetPixel, GetWidthBytes, and ToImage methods to use the cached value instead of recalculating

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adcondev adcondev moved this to In progress in POS RED2000 Feb 12, 2026
@adcondev adcondev merged commit bbd923e into master Feb 12, 2026
19 of 20 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in POS RED2000 Feb 12, 2026
@adcondev adcondev deleted the refactor-graphics-bitmap-cache-bytesperrow-17139310501292623649 branch February 12, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant