Energy companies jumped with the price of oil on Wednesday, but overall stocks finished only slightly higher as a quiet week of trading continued.
The price of US crude oil jumped 3% as fuel stockpiles kept shrinking, and that made investors more optimistic about energy company profits.
Strong earnings from video game maker Electronic Arts and chip maker Nvidia helped technology stocks move up.
However, weak results from Priceline and Disney hurt consumer-focused companies, and health care stocks also stumbled as drug companies fell.
Investors did not react much to President Donald Trump's surprise decision to fire FBI director James Comey on Tuesday evening.
US stocks also had little reaction to the French presidential election last weekend, although European indexes climbed following the win by centrist candidate Emmanuel Macron.
"It's almost as if the market has become numb," said Julian Emanuel, an equity strategist for UBS. "Investors are interpreting this as more noise."
The Standard & Poor's 500 index picked up 2.71 points, or 0.1%, to 2,399.63, a fraction of a point above the all-time high it set on Monday.
The Dow Jones industrial average shed 32.67 points, or 0.2%, to 20,943.11 as Disney and Boeing slumped.
The Nasdaq composite finished at a record for the fourth day in a row as it rose 8.56 points, or 0.1%, to 6,129.14.
The Russell 2000 index of small-company stocks was up 7.73 points, or 0.6%, to 1,399.59.
Oil prices made big gains as reports showed US crude stockpiles dropped by 5.2 million barrels last week.
That was bigger than analysts expected. Crude inventories are returning to more normal levels after they swelled to record highs the last few years.
Benchmark US crude surged 3.2%, to $47.33 a barrel in New York. Brent crude, the international standard, gained 3.1%, to $50.22 a barrel in London.
EOG Resources gained 3.2%, to 94.54 US dollars and Chevron added 1.4%, to $106.50.
Crude oil prices have fallen in recent weeks as investors wondered if the members of Opec and other key oil-producing countries will be able to limit production and support prices.