Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tinylib/msgp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2.3
Choose a base ref
...
head repository: tinylib/msgp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.2.4
Choose a head ref
  • 3 commits
  • 20 files changed
  • 1 contributor

Commits on Oct 29, 2024

  1. Fix omitempty on aliased types (#377)

    Instead of doing return, insert an `if` block to skip emitting zero fields.
    
    This also allows the check to be inserted at any level.
    
    Fixes #376
    
    Emitted code:
    
    ```Go
    // MarshalMsg implements msgp.Marshaler
    func (z TypeSamples) MarshalMsg(b []byte) (o []byte, err error) {
    	o = msgp.Require(b, z.Msgsize())
    	o = msgp.AppendArrayHeader(o, uint32(len(z)))
    	for zb0004 := range z {
    		// check for omitted fields
    		zb0001Len := uint32(2)
    		var zb0001Mask uint8 /* 2 bits */
    		_ = zb0001Mask
    		if z[zb0004].K == 0 {
    			zb0001Len--
    			zb0001Mask |= 0x1
    		}
    		if z[zb0004].V == 0 {
    			zb0001Len--
    			zb0001Mask |= 0x2
    		}
    		// variable map header, size zb0001Len
    		o = append(o, 0x80|uint8(zb0001Len))
    
    		// skip if no fields are to be emitted
    		if zb0001Len != 0 {
    			if (zb0001Mask & 0x1) == 0 { // if not omitted
    				// string "k"
    				o = append(o, 0xa1, 0x6b)
    				o = msgp.AppendUint32(o, z[zb0004].K)
    			}
    			if (zb0001Mask & 0x2) == 0 { // if not omitted
    				// string "v"
    				o = append(o, 0xa1, 0x76)
    				o = msgp.AppendUint32(o, z[zb0004].V)
    			}
    		}
    	}
    	return
    }
    ```
    
    If only 1 field, the check is omitted (and there is similar behavior on clearomitted).
    klauspost authored Oct 29, 2024
    Configuration menu
    Copy the full SHA
    1de3898 View commit details
    Browse the repository at this point in the history
  2. Escape field tags (#379)

    Fixes #266
    klauspost authored Oct 29, 2024
    Configuration menu
    Copy the full SHA
    62d06cc View commit details
    Browse the repository at this point in the history

Commits on Oct 30, 2024

  1. Add "newtime" directive to use official messagepack time format (#378)

    This adds `msgp:newtime` file directive that will encode all time fields using the -1 extension as defined in the [(revised) messagepack spec](https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type)
    
    ReadTime/ReadTimeBytes will now support both types natively, and will accept either as input.
    
    Extensions should remain unaffected.
    
    Fixes #300
    klauspost authored Oct 30, 2024
    Configuration menu
    Copy the full SHA
    4c71fd4 View commit details
    Browse the repository at this point in the history
Loading