@@ -457,20 +457,13 @@ static bool TryReadLine(ref ReadOnlySequence<byte> buffer, out ReadOnlySequence<
457457 var reader = new SequenceReader < byte > ( buffer ) ;
458458 const byte LF = ( byte ) '\n ' ;
459459
460- #pragma warning disable SA1003
461460 if (
462- #if LANG_VERSION_11_OR_GREATER
463- ! reader . TryReadTo ( out line , delimiter : "\r \n "u8 , advancePastDelimiter : true )
464- #else
465- ! reader . TryReadTo ( out line , delimiter : CRLF . Span , advancePastDelimiter : true )
466- #endif
467- &&
461+ ! reader . TryReadTo ( out line , delimiter : "\r \n "u8 , advancePastDelimiter : true ) &&
468462 ! reader . TryReadTo ( out line , delimiter : LF , advancePastDelimiter : true )
469463 ) {
470464 line = default ;
471465 return false ;
472466 }
473- #pragma warning restore SA1003
474467
475468#if SYSTEM_BUFFERS_SEQUENCEREADER_UNREADSEQUENCE
476469 buffer = reader . UnreadSequence ;
@@ -482,10 +475,6 @@ static bool TryReadLine(ref ReadOnlySequence<byte> buffer, out ReadOnlySequence<
482475 }
483476 }
484477
485- #if ! LANG_VERSION_11_OR_GREATER
486- private static readonly ReadOnlyMemory < byte > CRLF = Encoding . ASCII . GetBytes ( "\r \n " ) ;
487- #endif
488-
489478 private static bool ExpectCommand (
490479 ReadOnlySequence < byte > commandLine ,
491480 ReadOnlySpan < byte > expectedCommand ,
@@ -521,7 +510,6 @@ out ReadOnlySequence<byte> arguments
521510
522511 private static readonly byte CommandQuitShort = ( byte ) '.' ;
523512
524- #if LANG_VERSION_11_OR_GREATER
525513 private ValueTask RespondToCommandAsync (
526514 Socket client ,
527515 ReadOnlySequence < byte > commandLine ,
@@ -566,62 +554,6 @@ CancellationToken cancellationToken
566554 ) ;
567555 }
568556 }
569- #else
570- private static readonly ReadOnlyMemory < byte > commandFetch = Encoding . ASCII . GetBytes ( "fetch" ) ;
571- private static readonly ReadOnlyMemory < byte > commandNodes = Encoding . ASCII . GetBytes ( "nodes" ) ;
572- private static readonly ReadOnlyMemory < byte > commandList = Encoding . ASCII . GetBytes ( "list" ) ;
573- private static readonly ReadOnlyMemory < byte > commandConfig = Encoding . ASCII . GetBytes ( "config" ) ;
574- private static readonly ReadOnlyMemory < byte > commandQuit = Encoding . ASCII . GetBytes ( "quit" ) ;
575- private static readonly ReadOnlyMemory < byte > commandCap = Encoding . ASCII . GetBytes ( "cap" ) ;
576- private static readonly ReadOnlyMemory < byte > commandVersion = Encoding . ASCII . GetBytes ( "version" ) ;
577-
578- private ValueTask RespondToCommandAsync (
579- Socket client ,
580- ReadOnlySequence < byte > commandLine ,
581- CancellationToken cancellationToken
582- )
583- {
584- cancellationToken . ThrowIfCancellationRequested ( ) ;
585-
586- if ( ExpectCommand ( commandLine , commandFetch . Span , out var fetchArguments ) ) {
587- return ProcessCommandFetchAsync ( client , fetchArguments , cancellationToken ) ;
588- }
589- else if ( ExpectCommand ( commandLine , commandNodes . Span , out _ ) ) {
590- return ProcessCommandNodesAsync ( client , cancellationToken ) ;
591- }
592- else if ( ExpectCommand ( commandLine , commandList . Span , out var listArguments ) ) {
593- return ProcessCommandListAsync ( client , listArguments , cancellationToken ) ;
594- }
595- else if ( ExpectCommand ( commandLine , commandConfig . Span , out var configArguments ) ) {
596- return ProcessCommandConfigAsync ( client , configArguments , cancellationToken ) ;
597- }
598- else if (
599- ExpectCommand ( commandLine , commandQuit . Span , out _ ) ||
600- ( commandLine . Length == 1 && commandLine . FirstSpan [ 0 ] == commandQuitShort )
601- ) {
602- client . Close ( ) ;
603- #if SYSTEM_THREADING_TASKS_VALUETASK_COMPLETEDTASK
604- return ValueTask . CompletedTask ;
605- #else
606- return default ;
607- #endif
608- }
609- else if ( ExpectCommand ( commandLine , commandCap . Span , out var capArguments ) ) {
610- return ProcessCommandCapAsync ( client , capArguments , cancellationToken ) ;
611- }
612- else if ( ExpectCommand ( commandLine , commandVersion . Span , out _ ) ) {
613- return ProcessCommandVersionAsync ( client , cancellationToken ) ;
614- }
615- else {
616- return SendResponseAsync (
617- client : client ,
618- encoding : Encoding ,
619- responseLine : "# Unknown command. Try cap, list, nodes, config, fetch, version or quit" ,
620- cancellationToken : cancellationToken
621- ) ;
622- }
623- }
624- #endif
625557
626558#pragma warning disable IDE0230
627559 private static readonly ReadOnlyMemory < byte > EndOfLine = new [ ] { ( byte ) '\n ' } ;
0 commit comments