Eating a well-balanced diet is especially important during stressful times like having surgery. If your diet is deficient, taking a daily multivitamin will improve overall health. Vitamin C may speed up recovery after surgery. If at all possible, you should also have a planned program of exercise to strengthen the muscles around the hip or whatever joint is being operated on. Success is much greater with better endurance and strength.
General fitness is even more important here.
Above all, nothing is more important than keeping a positive attitude toward what will be a painful procedure. You have to remember that the relief of pain and increased function will be worth it. You must be prepared mentally to do whatever is needed following your operation even though you will hurt. For example, if you don't exercise, the muscles will stiffen, and your results will be less effective. If you are unwilling to do this, you probably should not have the operation.