"I focused on protecting my serve. It was not an easy match, I enjoyed it."
Federer takes a 16-2 record over Richard Gasquet into his third-round match.
Six-time champion Novak Djokovic showed iron-man stamina as he battled hothouse conditions to overcome fatigued Frenchman Gael Monfils 4-6, 6-3, 6-1, 6-3.
Djokovic, seeded 14th after not playing since Wimbledon due to an elbow injury, is showing that his comeback after six inactive months is starting to take flight. He advanced with 31 winners and seven breaks of serve.
But Djokovic is still dealing with his injury, which he admits is not yet perfect.
"It's still not 100 percent, but building," the 31-year-old said. "I have a lot of faith and self-belief. I know what I'm capable of. This is the most successful court of my career."
The contest featured several momentum shifts as both men battled the scorching heat.
Monfils said he felt dizzy and faint at some points, but had to play on as umpires enforced the role of 25 seconds only between points.
"No matter how much you train in the heat, how much you like the heat, is very tough. It was a tough decision I think for the official. It's a little bit hot, maybe a little bit too hot."
German fourth seed Alexander Zverev defeated compatriot Peter Gojowczyk 6-1, 6-3, 4-6, 6-3.