Skip to content

🧹 Standardize little-endian conversion using shared.ToLittleEndian#120

Draft
adcondev wants to merge 1 commit intomasterfrom
refactor-endian-conversion-5765992641875911768
Draft

🧹 Standardize little-endian conversion using shared.ToLittleEndian#120
adcondev wants to merge 1 commit intomasterfrom
refactor-endian-conversion-5765992641875911768

Conversation

@adcondev
Copy link
Owner

Standardized the little-endian conversion logic across the pkg/commands subpackages. Replaced manual & 0xFF and >> 8 bitwise operations with calls to shared.ToLittleEndian. This refactoring improves code consistency and maintainability. Verified with unit tests across all modified packages.


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

This commit replaces manual bitwise operations for little-endian byte conversion with the `shared.ToLittleEndian` utility function across multiple packages in `pkg/commands`.

Changes:
- Refactored `pkg/commands/printposition/print_position_commands.go`
- Refactored `pkg/commands/qrcode/qr_code_commands.go`
- Refactored `pkg/commands/bitimage/graphics_commands.go`
- Refactored `pkg/commands/bitimage/nv_graphics_commands.go`
- Refactored `pkg/commands/bitimage/download_graphics_commands.go`

These changes improve maintainability and readability by using a centralized conversion utility and standardizing the implementation pattern.

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.3119 ns/op	       0 B/op	       0 allocs/op
BenchmarkBuildSimple-4    	 3681320	       329.0 ns/op	     240 B/op	       4 allocs/op
BenchmarkBuildComplex-4   	  421584	      2793 ns/op	    1809 B/op	      25 allocs/op
BenchmarkToJSON-4         	  534897	      2078 ns/op	     592 B/op	       3 allocs/op
BenchmarkParseDocument_Minimal-4    	  510397	      2309 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Receipt-4    	   93420	     12582 ns/op	    2392 B/op	      34 allocs/op
BenchmarkCommandUnmarshal_Text-4    	  419428	      2721 ns/op	     568 B/op	      19 allocs/op
BenchmarkCommandUnmarshal_Table-4   	  276096	      4166 ns/op	     944 B/op	      21 allocs/op
BenchmarkTextCommandParsing-4       	  523056	      2127 ns/op	     544 B/op	      16 allocs/op
BenchmarkTableCommandParsing-4      	  246378	      4758 ns/op	    1000 B/op	      29 allocs/op
BenchmarkParseHexString-4           	 8650076	       135.7 ns/op	      48 B/op	       2 allocs/op
BenchmarkCleanHexString-4           	 6128292	       179.7 ns/op	      64 B/op	       2 allocs/op
BenchmarkContainsSequence-4         	366690955	         3.258 ns/op	       0 B/op	       0 allocs/op
BenchmarkCheckCriticalCommands-4    	36532964	        33.13 ns/op	       0 B/op	       0 allocs/op
BenchmarkDocument_Validate-4       	13214518	        93.47 ns/op	       0 B/op	       0 allocs/op
BenchmarkParseDocument_Simple-4    	  497432	      2399 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Complex-4   	  140462	      8510 ns/op	    1352 B/op	      26 allocs/op
BenchmarkPrintImage_Small-4             	     601	   1966837 ns/op	 3469938 B/op	      24 allocs/op
BenchmarkPrintImage_Medium-4            	     330	   3672738 ns/op	 5481086 B/op	      24 allocs/op
BenchmarkPrintImage_ThermalPreview-4    	     139	   8611078 ns/op	 5235278 B/op	  230723 allocs/op

Base Branch Results

BenchmarkNewDocument-4    	1000000000	         0.3120 ns/op	       0 B/op	       0 allocs/op
BenchmarkBuildSimple-4    	 3662874	       326.1 ns/op	     240 B/op	       4 allocs/op
BenchmarkBuildComplex-4   	  404808	      2765 ns/op	    1809 B/op	      25 allocs/op
BenchmarkToJSON-4         	  539031	      2075 ns/op	     592 B/op	       3 allocs/op
BenchmarkParseDocument_Minimal-4    	  499311	      2316 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Receipt-4    	   94102	     12615 ns/op	    2392 B/op	      34 allocs/op
BenchmarkCommandUnmarshal_Text-4    	  417324	      2713 ns/op	     568 B/op	      19 allocs/op
BenchmarkCommandUnmarshal_Table-4   	  278449	      4186 ns/op	     944 B/op	      21 allocs/op
BenchmarkTextCommandParsing-4       	  530960	      2131 ns/op	     544 B/op	      16 allocs/op
BenchmarkTableCommandParsing-4      	  245026	      4797 ns/op	    1000 B/op	      29 allocs/op
BenchmarkParseHexString-4           	 7678134	       162.0 ns/op	      48 B/op	       2 allocs/op
BenchmarkCleanHexString-4           	 6502686	       185.7 ns/op	      64 B/op	       2 allocs/op
BenchmarkContainsSequence-4         	295946215	         4.058 ns/op	       0 B/op	       0 allocs/op
BenchmarkCheckCriticalCommands-4    	32699736	        37.03 ns/op	       0 B/op	       0 allocs/op
BenchmarkDocument_Validate-4       	12825962	        96.16 ns/op	       0 B/op	       0 allocs/op
BenchmarkParseDocument_Simple-4    	  500451	      2390 ns/op	     568 B/op	      14 allocs/op
BenchmarkParseDocument_Complex-4   	  135920	      8496 ns/op	    1352 B/op	      26 allocs/op
BenchmarkPrintImage_Small-4             	     596	   1942583 ns/op	 3469935 B/op	      24 allocs/op
BenchmarkPrintImage_Medium-4            	     292	   3660573 ns/op	 5481085 B/op	      24 allocs/op
BenchmarkPrintImage_ThermalPreview-4    	     139	   8485991 ns/op	 5231177 B/op	  230423 allocs/op

💡 Note: Use benchstat for statistical comparison

🎯 Summary

  • Total Benchmarks: 32
  • Average Speed: 2586875 ns/op
  • Average Memory: 2396932 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