mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:22:43 +00:00 
			
		
		
		
	 3f3f45580a
			
		
	
	
		3f3f45580a
		
	
	
	
	
		
			
			Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			651 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			651 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020-2022, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <AK/StringBuilder.h>
 | |
| #include <AK/URL.h>
 | |
| #include <LibGemini/GeminiRequest.h>
 | |
| 
 | |
| namespace Gemini {
 | |
| 
 | |
| ByteBuffer GeminiRequest::to_raw_request() const
 | |
| {
 | |
|     StringBuilder builder;
 | |
|     builder.append(m_url.to_string());
 | |
|     builder.append("\r\n"sv);
 | |
|     return builder.to_byte_buffer();
 | |
| }
 | |
| 
 | |
| Optional<GeminiRequest> GeminiRequest::from_raw_request(ByteBuffer const& raw_request)
 | |
| {
 | |
|     URL url = StringView(raw_request);
 | |
|     if (!url.is_valid())
 | |
|         return {};
 | |
|     GeminiRequest request;
 | |
|     request.m_url = url;
 | |
|     return request;
 | |
| }
 | |
| 
 | |
| }
 |