The company credited market share gains and a better inventory position for the profit.