@@ -174,7 +174,7 @@ void appendRequiredFieldsToResponse(OperationContext* opCtx, BSONObjBuilder* res
174174 bool clusterTimeWasOutput = VectorClock::get (opCtx)->gossipOut (opCtx, responseBuilder);
175175
176176 // Ensure that either both operationTime and $clusterTime are output, or neither.
177- if (clusterTimeWasOutput) {
177+ if (MONGO_likely ( clusterTimeWasOutput) ) {
178178 auto operationTime = OperationTimeTracker::get (opCtx)->getMaxOperationTime ();
179179 if (VectorClock::isValidComponentTime (operationTime)) {
180180 LOGV2_DEBUG (22764 ,
@@ -283,15 +283,6 @@ void ExecCommandClient::_prologue() {
283283 StringDataSet topLevelFields (8 );
284284 for (auto && element : request.body ) {
285285 StringData fieldName = element.fieldNameStringData ();
286- if (fieldName == CommandHelpers::kHelpFieldName && element.type () == Bool &&
287- element.Bool ()) {
288- auto body = result->getBodyBuilder ();
289- body.append (CommandHelpers::kHelpFieldName ,
290- " help for: {} {}" _format (c->getName (), c->help ()));
291- CommandHelpers::appendSimpleCommandStatus (body, true , " " );
292- iassert (Status (ErrorCodes::SkipCommandExecution, " Already served help command" ));
293- }
294-
295286 uassert (ErrorCodes::FailedToParse,
296287 " Parsed command object contains duplicate top level key: {}" _format (fieldName),
297288 topLevelFields.insert (fieldName).second );
@@ -305,7 +296,7 @@ void ExecCommandClient::_prologue() {
305296 iassert (Status (ErrorCodes::SkipCommandExecution, " Failed to check authorization" ));
306297 }
307298
308- if (shouldLog (logv2::LogComponent::kTracking , logv2::LogSeverity::Debug (1 ))) {
299+ if (MONGO_unlikely ( shouldLog (logv2::LogComponent::kTracking , logv2::LogSeverity::Debug (1 ) ))) {
309300 rpc::TrackingMetadata trackingMetadata;
310301 trackingMetadata.initWithOperName (c->getName ());
311302 rpc::TrackingMetadata::get (opCtx) = trackingMetadata;
@@ -625,11 +616,21 @@ void ParseAndRunCommand::_parseCommand() {
625616 }
626617 }
627618
628- if (!readConcernParseStatus.isOK ()) {
619+ if (MONGO_unlikely ( !readConcernParseStatus.isOK () )) {
629620 auto builder = replyBuilder->getBodyBuilder ();
630621 CommandHelpers::appendCommandStatusNoThrow (builder, readConcernParseStatus);
631622 iassert (Status (ErrorCodes::SkipCommandExecution, " Failed to parse read concern" ));
632623 }
624+
625+ if (MONGO_unlikely (_requestArgs.getHelp ().value_or (false ))) {
626+ const Command* c = _invocation->definition ();
627+ auto result = _rec->getReplyBuilder ();
628+ auto body = result->getBodyBuilder ();
629+ body.append (CommandHelpers::kHelpFieldName ,
630+ " help for: {} {}" _format (c->getName (), c->help ()));
631+ CommandHelpers::appendSimpleCommandStatus (body, true , " " );
632+ iassert (Status (ErrorCodes::SkipCommandExecution, " Already served help command" ));
633+ }
633634}
634635
635636bool isInternalClient (OperationContext* opCtx) {
@@ -672,7 +673,7 @@ Status ParseAndRunCommand::RunInvocation::_setup() {
672673 return Status (ErrorCodes::SkipCommandExecution, status.reason ());
673674 };
674675
675- if (_parc->_isHello .value ()) {
676+ if (MONGO_unlikely ( _parc->_isHello .value () )) {
676677 // Preload generic ClientMetadata ahead of our first hello request. After the first
677678 // request, metaElement should always be empty.
678679 auto metaElem = request.body [kMetadataDocumentName ];
@@ -681,9 +682,9 @@ Status ParseAndRunCommand::RunInvocation::_setup() {
681682
682683 enforceRequireAPIVersion (opCtx, command);
683684
684- auto & apiParams = APIParameters::get (opCtx);
685- auto & apiVersionMetrics = APIVersionMetrics::get (opCtx->getServiceContext ());
686685 if (auto clientMetadata = ClientMetadata::get (opCtx->getClient ())) {
686+ auto & apiParams = APIParameters::get (opCtx);
687+ auto & apiVersionMetrics = APIVersionMetrics::get (opCtx->getServiceContext ());
687688 auto appName = clientMetadata->getApplicationName ().toString ();
688689 apiVersionMetrics.update (appName, apiParams);
689690 }
@@ -719,7 +720,7 @@ Status ParseAndRunCommand::RunInvocation::_setup() {
719720 }
720721
721722 bool supportsWriteConcern = invocation->supportsWriteConcern ();
722- if (!supportsWriteConcern && requestArgs.getWriteConcern ()) {
723+ if (MONGO_unlikely ( !supportsWriteConcern && requestArgs.getWriteConcern () )) {
723724 // This command doesn't do writes so it should not be passed a writeConcern.
724725 const auto errorMsg = " Command does not support writeConcern" ;
725726 return appendStatusToReplyAndSkipCommandExecution ({ErrorCodes::InvalidOptions, errorMsg});
@@ -927,13 +928,12 @@ Status ParseAndRunCommand::RunInvocation::_setup() {
927928 //
928929 // Individual transaction statements are checked later on, after we've unstashed the transaction
929930 // resources.
930- if (!TransactionRouter::get (opCtx) && readConcernArgs.hasLevel ()) {
931- if (!readConcernSupport.readConcernSupport .isOK ()) {
932- const std::string errorMsg = " Command {} does not support {}" _format (
933- invocation->definition ()->getName (), readConcernArgs.toString ());
934- return appendStatusToReplyAndSkipCommandExecution (
935- readConcernSupport.readConcernSupport .withContext (errorMsg));
936- }
931+ if (MONGO_unlikely (!TransactionRouter::get (opCtx) && readConcernArgs.hasLevel () &&
932+ !readConcernSupport.readConcernSupport .isOK ())) {
933+ const std::string errorMsg = " Command {} does not support {}" _format (
934+ invocation->definition ()->getName (), readConcernArgs.toString ());
935+ return appendStatusToReplyAndSkipCommandExecution (
936+ readConcernSupport.readConcernSupport .withContext (errorMsg));
937937 }
938938
939939 // Remember whether or not this operation is starting a transaction, in case something later in
0 commit comments