TITLE: Proof of $f \in C_C(X)$ where $X$ is a metric space implies $f$ is uniformly continuous
QUESTION [5 upvotes]: Can you tell me if the following proof is correct?
Claim:
If $f$ is a continuous and compactly supported function from a metric space $X$ into $\mathbb{R}$ then $f$ is uniformly continuous.
Proof:
The proof is in two parts.
First we want to show that $f$ is uniformly continuous on $K := \operatorname{supp}{f}$:
Let $\varepsilon > 0$.
Because $f$ is continuous we have that for each $x$ in $K$ there is a $\delta_x$ such that for all $y$ with $d(x,y) < 2 \delta_x$ we have $|f(x) - f(y)| < \varepsilon$ and because $\{ B(x, \frac{\delta_x}{2}) \}_{x \in K}$ is an open cover of $K$ there is a finite subcover which we denote $\{ B(x_i, \frac{\delta_i}{2}) \}_{i=1}^n$. 
Define $\delta := \min_i \frac{\delta_i}{2}$ and let $x$ and $y$ be any two points in $K$ with $d(x,y) < \delta$. $\{ B(x_i, \frac{\delta_i}{2}) \}_{i=1}^n$ is a cover so there exists an $i$ such that $x$ is in $B(x_i, \frac{\delta_i}{2})$ which means that $d(x,x_i) < \frac{\delta_i}{2}$. Then $d(x_i ,y) \leq d(x_i ,x) + d(x,y) < \frac{\delta_i}{2} + \delta \leq \delta_i$ hence $y$ is also in $B(x_i, \delta_i)$.
Since $d(x_i,y) < \delta_i$ and $d(x, x_i) < \delta_i$ we have $|f(x) - f(y)| \leq |f(x) - f(x_i)| + |f(x_i) - f(y)| < 2 \varepsilon$.
Next we want to show that if $f$ is uniformly continuous on $K$ then it is uniformly continuous on all of $X$:
Let $\varepsilon > 0$. For any two points $x$ and $y$ we're done if either both are in $K$ or both are outside $K$ so let $x \in X \setminus K$ and $y \in K$ with $d(x,y) < \delta$. Then there is an $i$ such that $y$ is in $B(x_i, \frac{\delta_i}{2})$. Then $d(x,x_i) \leq d(x,y) + d(y,x_i) < \delta_i$ and hence $|f(x) - f(y)| \leq |f(x) - f(x_i)| + |f(x_i) - f(y)| < 2 \varepsilon$.
Is it necessary to prove this in two parts or is the second part "obvious" and should be left away?
Thanks for your help.

REPLY [4 votes]: That looks good except for the correction that t.b. pointed out.  In the spirit of Henning Makholm's comment, here is a "canned theorem" approach.
A continuous function on a compact metric space is uniformly continuous, so $f|_K$ is uniformly continuous.  Let $\varepsilon>0$ be given.  Then $K_\varepsilon:=\{x:|f(x)|\geq \varepsilon\}$ is a closed subset of $K$, hence compact, and $\{x:f(x)=0\}$ is a closed set disjoint from $K_\varepsilon$, so there is a positive distance $\delta_1$ between $K_\varepsilon$ and $\{x:f(x)=0\}$.  Let $\delta_2$ be such that if $x$ and $y$ are in $K$ and $d(x,y)<\delta_2$, then $|f(x)-f(y)|<\varepsilon$.  Let $\delta=\min\{\delta_1,\delta_2\}$.
If $x$ and $y$ are in $X$ and $d(x,y)<\delta$, then: 

$x$ and $y$ are both in $K$, and since $d(x,y)<\delta_2$, we have $|f(x)-f(y)|<\varepsilon$; or
one of $x$ or $y$ is not in $K$.  WLOG suppose $x$ is not in $K$.  Then $f(x)=0$, and since $d(x,y)<\delta_1$, $y$ is not in $K_\varepsilon$, meaning $|f(x)-f(y)|=|f(y)|<\varepsilon$. $\square$