TAYLOR SWIFT planned to spend an hour on Saturday visiting with patients on the pediatric cancer floor at New York City's Sloan-Kettering hospital . . . but she ended up staying four-and-half hours.

She spent a lot of time in the room of a 17-year-old girl named Shelby Huff . . . and told her how they almost ended up with the same first name.

She said, quote, "My parents almost named me Shelby, and then they realized my name would be 'Shelby Swift', like 'she'll be swift' and then what if I wasn't a fast runner?  Kids would be like, 'No, she's not!'"

Shelby wrote about the visit later on Facebook.  Quote, "We're still in awe.  Taylor was so sweet, compassionate, asked US questions, got on Skype, and was completely down to earth.  Thank you Taylor, you are a beautiful woman inside and out!"