fallintoplace commented on code in PR #1801:
URL: https://github.com/apache/iceberg-go/pull/1801#discussion_r3798007278


##########
table/metadata.go:
##########
@@ -596,20 +596,31 @@ func (b *MetadataBuilder) NextRowID() int64 {
 }
 
 func (b *MetadataBuilder) RemoveSnapshots(snapshotIds []int64, postCommit 
bool) error {
-       if b.currentSnapshotID != nil && slices.Contains(snapshotIds, 
*b.currentSnapshotID) {
-               return errors.New("current snapshot cannot be removed")
+       removedIDs := make(map[int64]struct{}, len(snapshotIds))
+       for _, snapshotID := range snapshotIds {
+               removedIDs[snapshotID] = struct{}{}
+       }
+
+       if b.currentSnapshotID != nil {
+               if _, ok := removedIDs[*b.currentSnapshotID]; ok {
+                       return errors.New("current snapshot cannot be removed")
+               }
        }
 
        b.snapshotList = slices.DeleteFunc(b.snapshotList, func(e Snapshot) 
bool {
-               return slices.Contains(snapshotIds, e.SnapshotID)
-       })
-       b.snapshotLog = slices.DeleteFunc(b.snapshotLog, func(e 
SnapshotLogEntry) bool {
-               return slices.Contains(snapshotIds, e.SnapshotID)
+               _, ok := removedIDs[e.SnapshotID]
+
+               return ok
        })

Review Comment:
   I can add a short comment here to make that less confusing.



-- 
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