Right-hander Reynaldo Lopez vowed to make the second half of his season better than his first.

To an extent, it was hard to imagine a scenario in which things got worse.

Having the highest ERA (6.34) among qualified starters in the majors before the All-Star break was a far cry from Lopez’ 2018 season.

‘‘Today after my outing, I was talking with one of the guys here, and we already figured out what I’m doing and what I need to do in order to get better,” Lopez said through a translator after his July 4 start in which he allowed six earned runs and nine hits in 5 1/3 innings. “That’s why I said the second half is going to be much, much better.’’

Since he said that: Twenty-one innings pitched in three starts, four earned runs allowed and 25 strikeouts to go along with a 1.71 ERA.

Even though he was credited with the loss, Lopez put together his third consecutive strong start on Wednesday in the Sox’ 2-0 defeat against the Marlins.

He flirted with a shutout until Cesar Puello hit a two-run homer in the eighth inning.

Lopez fanned 10 batters and 76 of his 97 pitches were strikes in his four-hit, two-runs allowed showing.

“You clearly see trust and confidence again in his stuff, conviction behind everything he’s doing,” manager Rick Renteria said. “He’s attacking, I mean he’s just getting after it. Staying down when he needs to, elevating. Using all his pitches very well, his secondary pitches.”

The confidence Lopez has been showing recently on the mound isn’t new. It’s reminiscent of when he emerged as arguably the Sox’ best starting pitcher last year when he finished the season with a 3.91 ERA in 188 2/3 innings. He was dominant down the stretch with a 1.13 ERA and 41 strikeouts in 40 innings in his last six starts.

Lopez said he has been motivated by his teammates working hard. He said right-hander Ivan Nova’s encouragement and catcher James McCann’s feedback has been instrumental in his improvements over the past few weeks.

Lopez said his mind has been in a better place.

“The break gave me the right amount of time to get my head in the right place,” Lopez said. “Focus pitch by pitch. The last three outings have been very good for me, but especially this one was a really good one.”