Skip to content

Commit ada176f

Browse files
committed
removed most global imports from std.uri
1 parent 385bd4d commit ada176f

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

std/uri.d

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,14 @@ module std.uri;
2525

2626
//debug=uri; // uncomment to turn on debugging writefln's
2727
debug(uri) private import std.stdio;
28-
29-
/* ====================== URI Functions ================ */
30-
31-
private import std.ascii;
32-
private import core.stdc.stdlib;
33-
private import std.utf;
3428
private import std.traits : isSomeChar;
35-
import core.exception : OutOfMemoryError;
36-
import std.exception;
3729

3830
/** This Exception is thrown if something goes wrong when encoding or
3931
decoding a URI.
4032
*/
4133
class URIException : Exception
4234
{
35+
import std.exception : basicExceptionCtors;
4336
mixin basicExceptionCtors;
4437
}
4538

@@ -74,6 +67,9 @@ private immutable ubyte[128] uri_flags = // indexed by character
7467

7568
private string URI_Encode(dstring string, uint unescapedSet)
7669
{
70+
import core.exception : OutOfMemoryError;
71+
import core.stdc.stdlib : alloca;
72+
7773
uint j;
7874
uint k;
7975
dchar V;
@@ -199,6 +195,10 @@ private uint ascii2hex(dchar c) @nogc @safe pure nothrow
199195

200196
private dstring URI_Decode(Char)(in Char[] uri, uint reservedSet) if (isSomeChar!Char)
201197
{
198+
import core.exception : OutOfMemoryError;
199+
import core.stdc.stdlib : alloca;
200+
import std.ascii : isHexDigit;
201+
202202
uint j;
203203
uint k;
204204
uint V;
@@ -314,8 +314,9 @@ private dstring URI_Decode(Char)(in Char[] uri, uint reservedSet) if (isSomeChar
314314

315315
string decode(Char)(in Char[] encodedURI) if (isSomeChar!Char)
316316
{
317+
import std.utf : toUTF8;
317318
auto s = URI_Decode(encodedURI, URI_Reserved | URI_Hash);
318-
return std.utf.toUTF8(s);
319+
return toUTF8(s);
319320
}
320321

321322
/*******************************
@@ -325,8 +326,9 @@ string decode(Char)(in Char[] encodedURI) if (isSomeChar!Char)
325326

326327
string decodeComponent(Char)(in Char[] encodedURIComponent) if (isSomeChar!Char)
327328
{
329+
import std.utf : toUTF8;
328330
auto s = URI_Decode(encodedURIComponent, 0);
329-
return std.utf.toUTF8(s);
331+
return toUTF8(s);
330332
}
331333

332334
/*****************************
@@ -336,7 +338,8 @@ string decodeComponent(Char)(in Char[] encodedURIComponent) if (isSomeChar!Char)
336338

337339
string encode(Char)(in Char[] uri) if (isSomeChar!Char)
338340
{
339-
auto s = std.utf.toUTF32(uri);
341+
import std.utf : toUTF32;
342+
auto s = toUTF32(uri);
340343
return URI_Encode(s, URI_Reserved | URI_Hash | URI_Alpha | URI_Digit | URI_Mark);
341344
}
342345

@@ -347,7 +350,8 @@ string encode(Char)(in Char[] uri) if (isSomeChar!Char)
347350

348351
string encodeComponent(Char)(in Char[] uriComponent) if (isSomeChar!Char)
349352
{
350-
auto s = std.utf.toUTF32(uriComponent);
353+
import std.utf : toUTF32;
354+
auto s = toUTF32(uriComponent);
351355
return URI_Encode(s, URI_Alpha | URI_Digit | URI_Mark);
352356
}
353357

@@ -405,6 +409,7 @@ ptrdiff_t uriLength(Char)(in Char[] s) if (isSomeChar!Char)
405409
* https://
406410
* www.
407411
*/
412+
import std.ascii : isAlphaNum;
408413
import std.uni : icmp;
409414

410415
ptrdiff_t i;
@@ -469,6 +474,8 @@ ptrdiff_t uriLength(Char)(in Char[] s) if (isSomeChar!Char)
469474
*/
470475
ptrdiff_t emailLength(Char)(in Char[] s) if (isSomeChar!Char)
471476
{
477+
import std.ascii : isAlpha, isAlphaNum;
478+
472479
ptrdiff_t i;
473480

474481
if (!isAlpha(s[0]))

0 commit comments

Comments
 (0)