[tor-commits] [goptlib/master] Use switch for keywordIsSafe.
dcf at torproject.org
dcf at torproject.org
Mon Jun 26 23:50:42 UTC 2017
commit 24207cb5ab5c782d70e29a837c8aeef8e01d61f5
Author: David Fifield <david at bamsoftware.com>
Date: Mon Jun 26 16:48:59 2017 -0700
Use switch for keywordIsSafe.
---
pt.go | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/pt.go b/pt.go
index 6b0dd09..39e6aca 100644
--- a/pt.go
+++ b/pt.go
@@ -217,19 +217,18 @@ func getenvRequired(key string) (string, error) {
// <KeywordChar> ::= <any US-ASCII alphanumeric, dash, and underscore>
func keywordIsSafe(keyword string) bool {
for _, b := range []byte(keyword) {
- if b >= '0' && b <= '9' {
+ switch {
+ case b >= '0' && b <= '9':
continue
- }
- if b >= 'A' && b <= 'Z' {
+ case b >= 'A' && b <= 'Z':
continue
- }
- if b >= 'a' && b <= 'z' {
+ case b >= 'a' && b <= 'z':
continue
- }
- if b == '-' || b == '_' {
+ case b == '-' || b == '_':
continue
+ default:
+ return false
}
- return false
}
return true
}
More information about the tor-commits
mailing list