@@ -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,13 @@ 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+ {
360+ return AbortWithErrorMessage ( CmdStrings . RESP_ERR_GENERIC_SYNTAX_ERROR ) ;
361+ }
360362
361363 if ( ! parseState . TryGetTimeout ( 4 , out var timeout , out var error ) )
362364 {
@@ -379,27 +381,26 @@ private bool ListBlockingPopPush()
379381
380382 var srcKey = parseState . GetArgSliceByRef ( 0 ) ;
381383 var dstKey = parseState . GetArgSliceByRef ( 1 ) ;
382- var rightOption = ArgSlice . FromPinnedSpan ( CmdStrings . RIGHT ) ;
383- var leftOption = ArgSlice . FromPinnedSpan ( CmdStrings . LEFT ) ;
384384
385385 if ( ! parseState . TryGetTimeout ( 2 , out var timeout , out var error ) )
386386 {
387387 return AbortWithErrorMessage ( error ) ;
388388 }
389389
390- return ListBlockingMove ( srcKey , dstKey , rightOption , leftOption , timeout ) ;
390+ return ListBlockingMove ( srcKey , dstKey , OperationDirection . Right ,
391+ OperationDirection . Left , timeout ) ;
391392 }
392393
393- private bool ListBlockingMove ( ArgSlice srcKey , ArgSlice dstKey , ArgSlice srcDir , ArgSlice dstDir , double timeout )
394+ private bool ListBlockingMove ( ArgSlice srcKey , ArgSlice dstKey ,
395+ OperationDirection sourceDirection ,
396+ OperationDirection destinationDirection ,
397+ double timeout )
394398 {
395399 var cmdArgs = new ArgSlice [ ] { default , default , default } ;
396400
397401 // Read destination key
398402 cmdArgs [ 0 ] = dstKey ;
399403
400- var sourceDirection = GetOperationDirection ( srcDir ) ;
401- var destinationDirection = GetOperationDirection ( dstDir ) ;
402-
403404 if ( sourceDirection == OperationDirection . Unknown || destinationDirection == OperationDirection . Unknown )
404405 {
405406 return AbortWithErrorMessage ( CmdStrings . RESP_ERR_GENERIC_SYNTAX_ERROR ) ;
@@ -770,13 +771,9 @@ private bool ListMove<TGarnetApi>(ref TGarnetApi storageApi)
770771 var srcKey = parseState . GetArgSliceByRef ( 0 ) ;
771772 var dstKey = parseState . GetArgSliceByRef ( 1 ) ;
772773
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 )
774+ if ( ! parseState . TryGetOperationDirection ( 2 , out var sourceDirection ) ||
775+ ! parseState . TryGetOperationDirection ( 3 , out var destinationDirection )
776+ )
780777 {
781778 return AbortWithErrorMessage ( CmdStrings . RESP_ERR_GENERIC_SYNTAX_ERROR ) ;
782779 }
@@ -964,10 +961,7 @@ private unsafe bool ListBlockingPopMultiple()
964961 var cmdArgs = new ArgSlice [ 2 ] ;
965962
966963 // Get the direction
967- var dir = parseState . GetArgSliceByRef ( currTokenId ++ ) ;
968- var popDirection = GetOperationDirection ( dir ) ;
969-
970- if ( popDirection == OperationDirection . Unknown )
964+ if ( ! parseState . TryGetOperationDirection ( currTokenId ++ , out var popDirection ) )
971965 {
972966 return AbortWithErrorMessage ( CmdStrings . RESP_ERR_GENERIC_SYNTAX_ERROR ) ;
973967 }
0 commit comments