worryg0d commented on code in PR #1939:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1939#discussion_r3017748926


##########
marshal.go:
##########
@@ -2923,9 +2923,13 @@ func (udt UDTTypeInfo) Marshal(value interface{}) 
([]byte, error) {
 func (udt UDTTypeInfo) Unmarshal(data []byte, value interface{}) error {
        // do this up here so we don't need to duplicate all of the map logic 
below
        if iptr, ok := value.(*interface{}); ok && iptr != nil {
-               v := map[string]interface{}{}
-               *iptr = v
+               var v map[string]interface{}
                value = &v
+               // Deffering this to the end of the method so dst var will hold 
updated map value
+               // 
https://issues.apache.org/jira/projects/CASSGO/issues/CASSGO-115
+               defer func() {
+                       *iptr = v
+               }()
        }

Review Comment:
   yeah, thinking about this now I would agree having a separate method is much 
better, at least from maintanability point of view
   
   this `defer func { *iptr = v }` magic is definetly something that potential 
contributor could really miss...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to