Skip to content

Conversation

@adcondev
Copy link
Owner

This PR refactors StoreRasterGraphicsInBuffer and StoreColumnGraphicsInBuffer in pkg/commands/bitimage/graphics_commands.go to use shared.ToLittleEndian instead of manual bitwise operations for converting totalSize to little-endian bytes.

Changes:

  • Replaced manual endian conversion for pL and pH with shared.ToLittleEndian(uint16(totalSize)).
  • Applied the change to both raster and column graphics commands.

Verification:

  • Verified that totalSize is checked against MaxStandardCommandSize (65535) before conversion, ensuring it fits in uint16.
  • Ran existing tests go test -v ./pkg/commands/bitimage/... which passed.
  • Verified that go vet passes.

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

Replaces manual endian conversion with `shared.ToLittleEndian` in
`StoreRasterGraphicsInBuffer` and `StoreColumnGraphicsInBuffer`
to improve maintainability and readability.

This aligns with the existing pattern used elsewhere in the codebase.

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

⚡ Benchmark Results

📈 Performance Comparison

📊 Click to expand detailed results

Current Branch Results

BenchmarkNewDocument-4    	1000000000	         0.2889 ns/op	       0 B/op	       0 allocs/op
BenchmarkBuildSimple-4    	 3506148	       334.1 ns/op	     240 B/op	       4 allocs/op
BenchmarkBuildComplex-4   	  425260	      2785 ns/op	    1809 B/op	      25 allocs/op
BenchmarkToJSON-4         	  613647	      2000 ns/op	     592 B/op	       3 allocs/op
BenchmarkParseDocument_Minimal-4    	  529725	      2219 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Receipt-4    	  107721	     10910 ns/op	    2392 B/op	      34 allocs/op
BenchmarkCommandUnmarshal_Text-4    	  444865	      2616 ns/op	     568 B/op	      19 allocs/op
BenchmarkCommandUnmarshal_Table-4   	  288750	      4026 ns/op	     944 B/op	      21 allocs/op
BenchmarkTextCommandParsing-4       	  556839	      2069 ns/op	     544 B/op	      16 allocs/op
BenchmarkTableCommandParsing-4      	  265264	      4461 ns/op	    1000 B/op	      29 allocs/op
BenchmarkParseHexString-4           	 8653726	       138.6 ns/op	      48 B/op	       2 allocs/op
BenchmarkCleanHexString-4           	 7153789	       172.7 ns/op	      64 B/op	       2 allocs/op
BenchmarkContainsSequence-4         	312380020	         3.891 ns/op	       0 B/op	       0 allocs/op
BenchmarkCheckCriticalCommands-4    	29056934	        40.95 ns/op	       0 B/op	       0 allocs/op
BenchmarkDocument_Validate-4       	16496112	        72.08 ns/op	       0 B/op	       0 allocs/op
BenchmarkParseDocument_Simple-4    	  504891	      2216 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Complex-4   	  160520	      7341 ns/op	    1352 B/op	      26 allocs/op
BenchmarkPrintImage_Small-4             	     444	   2577932 ns/op	 3469931 B/op	      24 allocs/op
BenchmarkPrintImage_Medium-4            	     260	   4712673 ns/op	 5481077 B/op	      24 allocs/op
BenchmarkPrintImage_ThermalPreview-4    	     139	   9156085 ns/op	 5235265 B/op	  230723 allocs/op

Base Branch Results

BenchmarkNewDocument-4    	1000000000	         0.2895 ns/op	       0 B/op	       0 allocs/op
BenchmarkBuildSimple-4    	 3466322	       341.9 ns/op	     240 B/op	       4 allocs/op
BenchmarkBuildComplex-4   	  421416	      2749 ns/op	    1809 B/op	      25 allocs/op
BenchmarkToJSON-4         	  599252	      1939 ns/op	     592 B/op	       3 allocs/op
BenchmarkParseDocument_Minimal-4    	  543781	      2149 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Receipt-4    	  110534	     10809 ns/op	    2392 B/op	      34 allocs/op
BenchmarkCommandUnmarshal_Text-4    	  450585	      2665 ns/op	     568 B/op	      19 allocs/op
BenchmarkCommandUnmarshal_Table-4   	  296224	      3984 ns/op	     944 B/op	      21 allocs/op
BenchmarkTextCommandParsing-4       	  562518	      2039 ns/op	     544 B/op	      16 allocs/op
BenchmarkTableCommandParsing-4      	  250311	      4449 ns/op	    1000 B/op	      29 allocs/op
BenchmarkParseHexString-4           	 8608809	       139.6 ns/op	      48 B/op	       2 allocs/op
BenchmarkCleanHexString-4           	 7258054	       165.1 ns/op	      64 B/op	       2 allocs/op
BenchmarkContainsSequence-4         	322122595	         3.850 ns/op	       0 B/op	       0 allocs/op
BenchmarkCheckCriticalCommands-4    	29103387	        40.89 ns/op	       0 B/op	       0 allocs/op
BenchmarkDocument_Validate-4       	16525442	        72.27 ns/op	       0 B/op	       0 allocs/op
BenchmarkParseDocument_Simple-4    	  546948	      2142 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Complex-4   	  165154	      7164 ns/op	    1352 B/op	      26 allocs/op
BenchmarkPrintImage_Small-4             	     561	   2036954 ns/op	 3469930 B/op	      24 allocs/op
BenchmarkPrintImage_Medium-4            	     297	   4112312 ns/op	 5481074 B/op	      24 allocs/op
BenchmarkPrintImage_ThermalPreview-4    	     151	   7933409 ns/op	 5235275 B/op	  230723 allocs/op

💡 Note: Use benchstat for statistical comparison

🎯 Summary

  • Total Benchmarks: 32
  • Average Speed: 3073750 ns/op
  • Average Memory: 2381091 B/op
  • Average Allocations: 41093 allocs/op

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant