Compare commits
	
		
			5 Commits
		
	
	
		
			v2.0.1
			...
			321e203778
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 321e203778 | |||
| 1ac5e05e1a | |||
| cc110b414f | |||
| 246706d4fc | |||
| 897124be27 | 
							
								
								
									
										2
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							@@ -14,7 +14,7 @@ jobs:
 | 
				
			|||||||
      - uses: actions/checkout@v4
 | 
					      - uses: actions/checkout@v4
 | 
				
			||||||
      - uses: erlef/setup-beam@v1
 | 
					      - uses: erlef/setup-beam@v1
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          otp-version: "28.0.4"
 | 
					          otp-version: "28.1"
 | 
				
			||||||
          gleam-version: "1.12.0"
 | 
					          gleam-version: "1.12.0"
 | 
				
			||||||
          rebar3-version: "3.25.1"
 | 
					          rebar3-version: "3.25.1"
 | 
				
			||||||
          elixir-version: "1.18.4"
 | 
					          elixir-version: "1.18.4"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,3 +12,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
- Improved parsing performance significantly and reduced memory usage up to 50%
 | 
					- Improved parsing performance significantly and reduced memory usage up to 50%
 | 
				
			||||||
- Significantly improved IPV4 parsing performance
 | 
					- Significantly improved IPV4 parsing performance
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## v2.0.2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Minor performance improvement for uris with userinfo
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ packages = [
 | 
				
			|||||||
  { name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" },
 | 
					  { name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" },
 | 
				
			||||||
  { name = "gleam_otp", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "7987CBEBC8060B88F14575DEF546253F3116EBE2A5DA6FD82F38243FCE97C54B" },
 | 
					  { name = "gleam_otp", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "7987CBEBC8060B88F14575DEF546253F3116EBE2A5DA6FD82F38243FCE97C54B" },
 | 
				
			||||||
  { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
 | 
					  { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
 | 
				
			||||||
  { name = "gleam_stdlib", version = "0.63.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "E1D5EC07638F606E48F0EA1556044DD805F2ACE9092A6F6AFBE4A0CC4DA21C2F" },
 | 
					  { name = "gleam_stdlib", version = "0.63.2", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "962B25C667DA07F4CAB32001F44D3C41C1A89E58E3BBA54F183B482CF6122150" },
 | 
				
			||||||
  { name = "gleam_time", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "DCDDC040CE97DA3D2A925CDBBA08D8A78681139745754A83998641C8A3F6587E" },
 | 
					  { name = "gleam_time", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "DCDDC040CE97DA3D2A925CDBBA08D8A78681139745754A83998641C8A3F6587E" },
 | 
				
			||||||
  { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
 | 
					  { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
 | 
				
			||||||
  { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
 | 
					  { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -168,7 +168,7 @@ fn parse_authority(str: String) -> Result(#(Uri, String), Nil) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn parse_authority_part(str: String) -> Result(#(Uri, String), Nil) {
 | 
					fn parse_authority_part(str: String) -> Result(#(Uri, String), Nil) {
 | 
				
			||||||
  let #(userinfo, rest) = parse_userinfo(str, "")
 | 
					  let #(userinfo, rest) = parse_userinfo(str)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  use #(host, rest) <- result.try(parse_host(rest))
 | 
					  use #(host, rest) <- result.try(parse_host(rest))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -180,8 +180,12 @@ fn parse_authority_part(str: String) -> Result(#(Uri, String), Nil) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// userinfo      = *( unreserved / pct-encoded / sub-delims / ":" )
 | 
					// userinfo      = *( unreserved / pct-encoded / sub-delims / ":" )
 | 
				
			||||||
fn parse_userinfo(str: String, userinfo: String) -> #(Option(String), String) {
 | 
					fn parse_userinfo(str: String) -> #(Option(String), String) {
 | 
				
			||||||
  use <- bool.guard(when: !string.contains(str, "@"), return: #(None, str))
 | 
					  use <- bool.guard(when: !string.contains(str, "@"), return: #(None, str))
 | 
				
			||||||
 | 
					  do_parse_userinfo(str, "")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn do_parse_userinfo(str: String, userinfo: String) -> #(Option(String), String) {
 | 
				
			||||||
  case str {
 | 
					  case str {
 | 
				
			||||||
    "@" <> rest -> #(Some(userinfo), rest)
 | 
					    "@" <> rest -> #(Some(userinfo), rest)
 | 
				
			||||||
    "" -> #(None, userinfo <> str)
 | 
					    "" -> #(None, userinfo <> str)
 | 
				
			||||||
@@ -202,7 +206,7 @@ fn parse_userinfo(str: String, userinfo: String) -> #(Option(String), String) {
 | 
				
			|||||||
          str,
 | 
					          str,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        Ok(#(part, rest)) -> parse_userinfo(rest, userinfo <> part)
 | 
					        Ok(#(part, rest)) -> do_parse_userinfo(rest, userinfo <> part)
 | 
				
			||||||
        Error(_) -> #(None, userinfo <> str)
 | 
					        Error(_) -> #(None, userinfo <> str)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -421,7 +425,7 @@ fn parse_ipv4address(str: String) {
 | 
				
			|||||||
//              / "1" 2DIGIT            ; 100-199
 | 
					//              / "1" 2DIGIT            ; 100-199
 | 
				
			||||||
//              / "2" %x30-34 DIGIT     ; 200-249
 | 
					//              / "2" %x30-34 DIGIT     ; 200-249
 | 
				
			||||||
//              / "25" %x30-35          ; 250-255
 | 
					//              / "25" %x30-35          ; 250-255
 | 
				
			||||||
pub fn parse_dec_octet(str: String) -> Result(#(String, String), Nil) {
 | 
					fn parse_dec_octet(str: String) -> Result(#(String, String), Nil) {
 | 
				
			||||||
  try_parsers(
 | 
					  try_parsers(
 | 
				
			||||||
    [
 | 
					    [
 | 
				
			||||||
      parse_this_then(_, [
 | 
					      parse_this_then(_, [
 | 
				
			||||||
@@ -486,7 +490,7 @@ pub fn parse_dec_octet(str: String) -> Result(#(String, String), Nil) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// reg-name      = *( unreserved / pct-encoded / sub-delims )
 | 
					// reg-name      = *( unreserved / pct-encoded / sub-delims )
 | 
				
			||||||
pub fn parse_reg_name(str: String) {
 | 
					fn parse_reg_name(str: String) {
 | 
				
			||||||
  // can't error
 | 
					  // can't error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case do_parse_reg_name(str, "") {
 | 
					  case do_parse_reg_name(str, "") {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,5 @@
 | 
				
			|||||||
import gleam/uri as uri2
 | 
					import gleam/uri as uri2
 | 
				
			||||||
import gluri as uri
 | 
					import gluri as uri
 | 
				
			||||||
import gluri/internal/parser
 | 
					 | 
				
			||||||
import glychee/benchmark
 | 
					import glychee/benchmark
 | 
				
			||||||
import glychee/configuration
 | 
					import glychee/configuration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -15,43 +14,43 @@ pub fn main() {
 | 
				
			|||||||
  // ip_benchmark()
 | 
					  // ip_benchmark()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@target(erlang)
 | 
					// @target(erlang)
 | 
				
			||||||
pub fn ip_benchmark() {
 | 
					// pub fn ip_benchmark() {
 | 
				
			||||||
  benchmark.run(
 | 
					//   benchmark.run(
 | 
				
			||||||
    [
 | 
					//     [
 | 
				
			||||||
      benchmark.Function("ip_benchmark", fn(data) {
 | 
					//       benchmark.Function("ip_benchmark", fn(data) {
 | 
				
			||||||
        fn() {
 | 
					//         fn() {
 | 
				
			||||||
          let _ = parser.parse_dec_octet(data)
 | 
					//           let _ = parser.parse_dec_octet(data)
 | 
				
			||||||
          Nil
 | 
					//           Nil
 | 
				
			||||||
        }
 | 
					//         }
 | 
				
			||||||
      }),
 | 
					//       }),
 | 
				
			||||||
    ],
 | 
					//     ],
 | 
				
			||||||
    [
 | 
					//     [
 | 
				
			||||||
      benchmark.Data("173", "173"),
 | 
					//       benchmark.Data("173", "173"),
 | 
				
			||||||
      benchmark.Data("5", "5"),
 | 
					//       benchmark.Data("5", "5"),
 | 
				
			||||||
      benchmark.Data("200", "200"),
 | 
					//       benchmark.Data("200", "200"),
 | 
				
			||||||
      benchmark.Data("255", "255"),
 | 
					//       benchmark.Data("255", "255"),
 | 
				
			||||||
      benchmark.Data("fail", "2b"),
 | 
					//       benchmark.Data("fail", "2b"),
 | 
				
			||||||
    ],
 | 
					//     ],
 | 
				
			||||||
  )
 | 
					//   )
 | 
				
			||||||
}
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@target(erlang)
 | 
					// @target(erlang)
 | 
				
			||||||
pub fn reg_name_benchmark() {
 | 
					// pub fn reg_name_benchmark() {
 | 
				
			||||||
  benchmark.run(
 | 
					//   benchmark.run(
 | 
				
			||||||
    [
 | 
					//     [
 | 
				
			||||||
      benchmark.Function("reg_name_benchmark", fn(data) {
 | 
					//       benchmark.Function("reg_name_benchmark", fn(data) {
 | 
				
			||||||
        fn() {
 | 
					//         fn() {
 | 
				
			||||||
          let _ = parser.parse_reg_name(data)
 | 
					//           let _ = parser.parse_reg_name(data)
 | 
				
			||||||
          Nil
 | 
					//           Nil
 | 
				
			||||||
        }
 | 
					//         }
 | 
				
			||||||
      }),
 | 
					//       }),
 | 
				
			||||||
    ],
 | 
					//     ],
 | 
				
			||||||
    [
 | 
					//     [
 | 
				
			||||||
      benchmark.Data("long", "github.com"),
 | 
					//       benchmark.Data("long", "github.com"),
 | 
				
			||||||
    ],
 | 
					//     ],
 | 
				
			||||||
  )
 | 
					//   )
 | 
				
			||||||
}
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@target(erlang)
 | 
					@target(erlang)
 | 
				
			||||||
pub fn parse_benchmark() {
 | 
					pub fn parse_benchmark() {
 | 
				
			||||||
@@ -75,6 +74,10 @@ pub fn parse_benchmark() {
 | 
				
			|||||||
        "long",
 | 
					        "long",
 | 
				
			||||||
        "https://github.com/gleam-lang/stdlib/issues/523#issuecomment-3288230480",
 | 
					        "https://github.com/gleam-lang/stdlib/issues/523#issuecomment-3288230480",
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
 | 
					      benchmark.Data(
 | 
				
			||||||
 | 
					        "with user",
 | 
				
			||||||
 | 
					        "https://test_name:user%20$$$@github.com/gleam-lang/stdlib/issues/523#issuecomment-3288230480",
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
      benchmark.Data("ipv4", "https://192.255.36.4/"),
 | 
					      benchmark.Data("ipv4", "https://192.255.36.4/"),
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,27 @@ pub fn main() {
 | 
				
			|||||||
  startest.run(startest.default_config())
 | 
					  startest.run(startest.default_config())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn parse_general_tests() {
 | 
				
			||||||
 | 
					  describe("general parsing", [
 | 
				
			||||||
 | 
					    it("mailto parsing", fn() {
 | 
				
			||||||
 | 
					      uri.parse("mailto:Joe@example.com")
 | 
				
			||||||
 | 
					      |> should.equal(Ok(
 | 
				
			||||||
 | 
					        Uri(..empty, scheme: Some("mailto"), path: "Joe@example.com"),
 | 
				
			||||||
 | 
					      ))
 | 
				
			||||||
 | 
					      uri.parse("mailto:Joe@example.com?hello#bye")
 | 
				
			||||||
 | 
					      |> should.equal(Ok(
 | 
				
			||||||
 | 
					        Uri(
 | 
				
			||||||
 | 
					          ..empty,
 | 
				
			||||||
 | 
					          scheme: Some("mailto"),
 | 
				
			||||||
 | 
					          path: "Joe@example.com",
 | 
				
			||||||
 | 
					          query: Some("hello"),
 | 
				
			||||||
 | 
					          fragment: Some("bye"),
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					      ))
 | 
				
			||||||
 | 
					    }),
 | 
				
			||||||
 | 
					  ])
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn parse_scheme_tests() {
 | 
					pub fn parse_scheme_tests() {
 | 
				
			||||||
  describe("scheme parsing", [
 | 
					  describe("scheme parsing", [
 | 
				
			||||||
    it("simple parse", fn() {
 | 
					    it("simple parse", fn() {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user