@@ -226,10 +226,7 @@ private unsafe bool ListPopMultiple<TGarnetApi>(ref TGarnetApi storageApi)
226226 }
227227
228228 // Get the direction
229- var dir = parseState . GetArgSliceByRef ( currTokenId ++ ) ;
230- var popDirection = GetOperationDirection ( dir ) ;
231-
232- if ( popDirection == OperationDirection . Unknown )
229+ if ( ! parseState . TryGetOperationDirection ( currTokenId ++ , out var popDirection ) )
233230 {
234231 return AbortWithErrorMessage ( CmdStrings . RESP_ERR_GENERIC_SYNTAX_ERROR ) ;
235232 }
@@ -355,8 +352,12 @@ private unsafe bool ListBlockingMove()
355352
356353 var srcKey = parseState . GetArgSliceByRef ( 0 ) ;
357354 var dstKey = parseState . GetArgSliceByRef ( 1 ) ;
358- var srcDir = parseState . GetArgSliceByRef ( 2 ) ;
359- var dstDir = parseState . GetArgSliceByRef ( 3 ) ;
355+
356+ if ( ! parseState . TryGetOperationDirection ( 2 , out var srcDir ) ||
357+ ! parseState . TryGetOperationDirection ( 3 , out var dstDir ) )
358+ {
359+ return AbortWithErrorMessage ( CmdStrings . RESP_ERR_GENERIC_SYNTAX_ERROR ) ;
360+ }
360361
361362 if ( ! parseState . TryGetTimeout ( 4 , out var timeout , out var error ) )
362363 {
@@ -379,27 +380,26 @@ private bool ListBlockingPopPush()
379380
380381 var srcKey = parseState . GetArgSliceByRef ( 0 ) ;
381382 var dstKey = parseState . GetArgSliceByRef ( 1 ) ;
382- var rightOption = ArgSlice . FromPinnedSpan ( CmdStrings . RIGHT ) ;
383- var leftOption = ArgSlice . FromPinnedSpan ( CmdStrings . LEFT ) ;
384383
385384 if ( ! parseState . TryGetTimeout ( 2 , out var timeout , out var error ) )
386385 {
387386 return AbortWithErrorMessage ( error ) ;
388387 }
389388
390- return ListBlockingMove ( srcKey , dstKey , rightOption , leftOption , timeout ) ;
389+ return ListBlockingMove ( srcKey , dstKey , OperationDirection . Right ,
390+ OperationDirection . Left , timeout ) ;
391391 }
392392
393- private bool ListBlockingMove ( ArgSlice srcKey , ArgSlice dstKey , ArgSlice srcDir , ArgSlice dstDir , double timeout )
393+ private bool ListBlockingMove ( ArgSlice srcKey , ArgSlice dstKey ,
394+ OperationDirection sourceDirection ,
395+ OperationDirection destinationDirection ,
396+ double timeout )
394397 {
395398 var cmdArgs = new ArgSlice [ ] { default , default , default } ;
396399
397400 // Read destination key
398401 cmdArgs [ 0 ] = dstKey ;
399402
400- var sourceDirection = GetOperationDirection ( srcDir ) ;
401- var destinationDirection = GetOperationDirection ( dstDir ) ;
402-
403403 if ( sourceDirection == OperationDirection . Unknown || destinationDirection == OperationDirection . Unknown )
404404 {
405405 return AbortWithErrorMessage ( CmdStrings . RESP_ERR_GENERIC_SYNTAX_ERROR ) ;
@@ -770,13 +770,8 @@ private bool ListMove<TGarnetApi>(ref TGarnetApi storageApi)
770770 var srcKey = parseState . GetArgSliceByRef ( 0 ) ;
771771 var dstKey = parseState . GetArgSliceByRef ( 1 ) ;
772772
773- var srcDirSlice = parseState . GetArgSliceByRef ( 2 ) ;
774- var dstDirSlice = parseState . GetArgSliceByRef ( 3 ) ;
775-
776- var sourceDirection = GetOperationDirection ( srcDirSlice ) ;
777- var destinationDirection = GetOperationDirection ( dstDirSlice ) ;
778-
779- if ( sourceDirection == OperationDirection . Unknown || destinationDirection == OperationDirection . Unknown )
773+ if ( ! parseState . TryGetOperationDirection ( 2 , out var sourceDirection ) ||
774+ ! parseState . TryGetOperationDirection ( 3 , out var destinationDirection ) )
780775 {
781776 return AbortWithErrorMessage ( CmdStrings . RESP_ERR_GENERIC_SYNTAX_ERROR ) ;
782777 }
@@ -964,10 +959,7 @@ private unsafe bool ListBlockingPopMultiple()
964959 var cmdArgs = new ArgSlice [ 2 ] ;
965960
966961 // Get the direction
967- var dir = parseState . GetArgSliceByRef ( currTokenId ++ ) ;
968- var popDirection = GetOperationDirection ( dir ) ;
969-
970- if ( popDirection == OperationDirection . Unknown )
962+ if ( ! parseState . TryGetOperationDirection ( currTokenId ++ , out var popDirection ) )
971963 {
972964 return AbortWithErrorMessage ( CmdStrings . RESP_ERR_GENERIC_SYNTAX_ERROR ) ;
973965 }
0 commit comments